首先,你一定会创建好ViewController 和tableViewCell的类文件。
那在tableViewCell。h中写好声明用到的属性,如图1.

然后是在。m中写好计算cell高度的方法,如图2.

接下来就是回到Viewontroller中在tableview的协议方法中调用方法。
通过-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;方法,如图3.

然后再根据用到的协议方法编写,
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;
等等。。。
网友评论