0

enter image description here

I have Implemented tableview named as mytableview inside UIView in UITableviewController named as maintablevew,and also I dynamically increased mytableview height based on cells count.it getting Increased Dynamically,Here my problem is when mytableview height getting increased I can't scroll upto bottom because I can't increased UIView height Dynamically,I don't know how to increase,can anyone suggest? Below code I used to increase mytableview height Dynamically.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    CGFloat numberOfRows =roomlabel.count;

    CGRect tableViewFrame = tableView.frame;
    tableViewFrame.size.height = numberOfRows * _mytableview.rowHeight;
    _mytableview.frame = tableViewFrame;

    return numberOfRows;
}
Shubam Gupta
  • 61
  • 1
  • 11
  • add a height constraint to your view, create a IBOutlet to height constraint and finally update the constraint's constant value to `numberOfRows * _mytableview.rowHeight;` finally call `layoutIfNeeded` on your view to reflect constraint value change – Sandeep Bhandari Dec 14 '17 at 06:53
  • ok let I check and where would I call layoutIfNeeded method ....can send the sample code for this issues. – Shubam Gupta Dec 14 '17 at 06:56
  • Share your requirement screen shot. Because if you set the frame(with all cells heights) to UITableView, then all cells are think they are in visible state. Then how can they scroll?. So embedded your table view in inside scroll view. – phani Dec 14 '17 at 07:04
  • I uploaded my screenload...Bottom i have a cell, but I can't able to scroll – Shubam Gupta Dec 14 '17 at 09:26
  • Is that UIView subview of Cell in UITableViewController , where you have added the myTableView? – Arun Kumar Dec 14 '17 at 09:32
  • yes UIView is subview of cell in uitableviewcontroller and I added mytableview inside of uiview – Shubam Gupta Dec 14 '17 at 09:51
  • email no and mobile number are textfields, bottom I have designed UItableview – Shubam Gupta Dec 14 '17 at 09:55

1 Answers1

0

You don't need to increase(change) the height of the UITableView or UIView, You just have to provide cell height, It will automatically update it's content size, and table will become scrollable.

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
CGFloat numberOfRows =roomlabel.count;
return numberOfRows; }
  • first I used this code to populate array values but when I scroll the tableview the top values are getting hide for that I increased my tableview height dynamically?? and if I increase my view height also means it works perfect ,I don't know how to do that,..... – Shubam Gupta Dec 14 '17 at 09:54