开发者

expandable and collapsable uitableviewcell [duplicate]

This question already has an answer here: 开发者_运维知识库 Table view cell expandable iOS (1 answer) Closed 9 years ago.

I want to achieve something like an expandable and collapsible UITableViewCell. The part of collapsing and expanding on user tap has been achieved, but what i am looking for is the feature of showing more and less.

That is, when the UITableViewCell has not expanded to show full view, the word "more" should be displayed. When the UITableViewCell is expanded, it should show the word "less" at the end. So whenever the user taps on more, then only the UITableView should expand and vice versa. Any ideas on how I could do this? Something like on web pages. When u click on more link it expands the area and lets u see its entire content.


Expanding on iWasRobbed's answer, you are looking for WWDC 2010 Session 128, Mastering Table Views, which you can officially find at apple.com.

It includes a demo of expanding table cells by updating the values returned by tableView:heightForRowAtIndexPath: then calling:

[tableView beginUpdates];
[tableView endUpdates];

on the UITableView. Since you don't need to change which rows are shown, you don't need to include any code between begin and end. Once endUpdates is called, the heights of all the rows are re-calculated by calls to tableView:heightForRowAtIndexPath: for each row.

The video includes examples of how to animate the updates, including how to disable the animations.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜