Dynamically increase UIView Height when Tableview Height get Increased Using Objective C?

700 Views Asked by At

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;
}
1

There are 1 best solutions below

1
On

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; }