开发者

expandable and collapsable uitableviewcell [duplicate]

开发者 https://www.devze.com 2023-01-10 14:08 出处:网络
This question already has an answer here: 开发者_运维知识库 Table view cell expandable iOS (1 answer)
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

精彩评论

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

关注公众号