In the case of iOS8, the cell can be automatically resized by adding two more lines after adding a constraint to the cell in storyboard.
1 Self.tableView.estimatedRowHeight = not 0; 2 Self.tableView.rowHeight = uitableviewautomaticdimension;
But now most of the applications are still need to support iOS7, so on the basis above, and then in the TableView agent method to add the following can be resolved, before you forget to add a property
@property (Strong, nonatomic) Sdtableviewcell *ccll;
and initialize
-(void) viewdidload { [super Viewdidload]; // additional setup after loading the view, typically from a nib. _CCLL = [Self.tableview dequeuereusablecellwithidentifier:@ "cc"];
Self.tableView.estimatedRowHeight = not 0; Self.tableView.rowHeight = uitableviewautomaticdimension;
}
In the Proxy method:
-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) Indexpath {Sdtableviewcell*cell = (Sdtableviewcell *) _ccll; Cell.label.text=Arr[indexpath.row]; [Cell setneedsupdateconstraints]; [Cell updateconstraintsifneeded]; Cell.bounds= CGRectMake (0.0f,0.0f, Cgrectgetwidth (tableview.bounds), Cgrectgetheight (cell.bounds)); [Cell setneedslayout]; [Cell layoutifneeded]; CGFloat height=[Cell.contentview systemlayoutsizefittingsize:uilayoutfittingcompressedsize].height; NSLog (@"hei%f", height);//add 1 of the split line, or it'll be almost returnHeight +1;}
can automatically adjust the height according to the content.
Use AutoLayout on iOS7 to allow cell to automatically adjust height