如何在iphone的tableview中增加单元格的高度? [英] How to increase the height of the cell in a tableview in iphone?

查看:104
本文介绍了如何在iphone的tableview中增加单元格的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iphone开发的新手。我正在解析一个xml文件,并在表格的每一行显示标题,日期,视图和摘要.summar的内容很大,所以在单元格中只显示前3个单词。如何根据内容的长度增加行的高度。所有内容都应该适合放在单元格中,并且应该显示完整的内容。请帮帮我。谢谢。

I am new to iphone development.I am parsing a xml file and displaying the title, date, view and summary in each row of a table.The contents of summar is big ,so only first 3 words are displayed in the cell.How can i increase the height of the row with respect to the length of the contents.All the content should fit properly inside the cell and full content should be displayed.Please help me out.Thanks.

推荐答案

您可以在tableView.delegate / datasource中执行此操作:

You can do this in your tableView.delegate/datasource:

- (CGFloat)tableView:(UITableView *)aTableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
   switch (indexPath.row){
       case 0:
         if(indexPath.section==0)
            return 123.0; // first row is 123pt high
       default:
         return 40.0; // all other rows are 40pt high 
   }
}

但这确实如此减慢滚动性能。理想情况下,您应使用 tableview.rowHeight 将所有行的行高设置为相同。

This does however slow down scroll performance. Ideally you should set the row height for all rows to be identical using tableview.rowHeight.

这篇关于如何在iphone的tableview中增加单元格的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆