1. Code implementation cell Highly adaptive method
Implemented by code, you need to calculate the height of each control, and then get a cell's
Total height, it is more common to calculate the required height by lable text.
Cgsize labelsize = [@ "asdassdas" sizewithfont:font constrainedtosize:cgsizemake (320,2000 ) Linebreakmode:nslinebreakmodewordwrap];
This allows you to calculate the height of the display, which can be put back in the agent's method within the cell. To be fulfilled today.
is to achieve the desired height through auto layout, which is achieved by using a third-party library (Https://github.com/forkingdog/UITableView-FDTemplateLayoutCell), simplifying the implementation , use this
The library allows you to focus on setting constraints, download and drag the uitableview+fdtemplatelayoutcell.h,uitableview+fdtemplatelayoutcell.m into the project, or you can install through the pod.
2. Achieving results
3. Implementing the Code
-(Nsinteger) Numberofsectionsintableview: (UITableView *) tableview{return 1;}-(Nsinteger) TableView: (UITableView *) TableView numberofrowsinsection: (nsinteger) section{return[Arrdata Count];}-(UITableViewCell *) TableView: (UITableView *) TableView Cellforrowatindexpath: (Nsindexpath *) indexpath{Mytableviewcell*cell = [Self.tabview dequeuereusablecellwithidentifier:@"CTF"]; Cell.txt.text=[Arrdata ObjectAtIndex:indexPath.row]; Cell.img.image=[uiimage imagenamed:@"a.jpg"]; returncell;}-(CGFloat) TableView: (UITableView *) TableView Heightforrowatindexpath: (Nsindexpath *) indexpath{return[TableView Fd_heightforcellwithidentifier:@"CTF"configuration:^ (Mytableviewcell *cell) {Cell.txt.text=[Arrdata ObjectAtIndex:indexPath.row]; Cell.img.image=[uiimage imagenamed:@"a.jpg"]; }];}
Upload more trouble, need to demo can stay in the mailbox, I will send in time.
IOS XIB Cell Adaptive Height implementation