0

I am new to iOS Programming, I have implemented UITableviewController. I placed UIView inside of UITableView. I designed label, textfields and tableview inside of UIView. Here My problem is, When I increasing the dynamic tableview based on array count, I want to increase my UIView height also. I don't know how to do that?? Below is my design structure,

UITableViewController---          
       UIView-----               (1)
           Label---Label         (2)
           label---Label         (3)
           label---              (4)
           UItableview           (5)
           textfield             (6)
           textfield             (7)
and so on

below I have successfully increase the (5) height and also I want to increase (1) height I don't know how to do?? can any one suggest solution for this?? I have tried this below code.

-(void)viewDidLayoutSubviews{


    CGFloat numberofrows=creditList.count;
    height = numberofrows*propertytable.rowHeight;
    _tableviewheight.constant = height;

    propertytable.frame =CGRectMake(propertytable.frame.origin.x,propertytable.frame.origin.y, propertytable.frame.size.width,_tableviewheight.constant);
    CGRect myviewframe=mainview.frame;
    NSLog(@"The myviewframe value is %f",myviewframe.size.height);


    mainview.translatesAutoresizingMaskIntoConstraints=YES;
    myviewframe.size.height=5000;

    mainview.frame=myviewframe;
    mainview.frame = CGRectMake(0,0,mainview.frame.size.width, 5000);
    mainview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
    mainview.contentMode = UIViewContentModeScaleAspectFit;
[mainview layoutIfNeeded];

      }
8
  • UILabel(1) and UILabel(2) are static or dynamic ? Commented Dec 22, 2017 at 12:49
  • Why you used another tableview inside a table view controller. You can use sections or if first view is static take it as table view header. You can drag a uiview into table view. If you know auto layouts dynamic height of table view cell is very easy. Commented Dec 22, 2017 at 12:56
  • It not a tableviewcontroller,I used tableview I want to populate the array values dynamically that Why I used?? Commented Dec 22, 2017 at 13:00
  • I mentioned that number are static I designed my ui into view.the only (5) tableview is dynamic Commented Dec 22, 2017 at 13:02
  • After Increased (5) height I can't scroll upto bottom because I want to increase my uiview height also. Commented Dec 22, 2017 at 13:04

1 Answer 1

1

If object has autolayout, try this:

- (void)viewDidLoad {
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    self.tableView.estimatedRowHeight = 105; //Default Height
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return UITableViewAutomaticDimension;
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.