首先,你一定会创建好ViewController 和tableViewCell的类文件。
那在tableViewCell。h中写好声明用到的属性,如图1.
如图1 。h文件中的声明
然后是在。m中写好计算cell高度的方法,如图2.
如图2.m文件中的计算方法
接下来就是回到Viewontroller中在tableview的协议方法中调用方法。
通过-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;方法,如图3.
如图3 heightForRowAtIndexPath方法
然后再根据用到的协议方法编写,
1、- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
2、- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
3、- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
4、- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
5、- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectio;
等等。。。