ken
ken

Reputation: 131

iOS, how to split UITableView into two

I want to split UITableView into two parts, top part and bottom part when I tap somewhere. the hidden part will open with animation. could anybody please tell me how to do that?

This effect just like at iOS app groups at desktop.

I think "how to split anyview into two parts" is what i want.

My fitst thought is that write code to take a shot of current screen as an image, and disabled the top and the bottom parts. then move down the bottom part.

I don't konw is there an API to do that quickly? or there already exists a repo on Github.

here is a sample image http://oi40.tinypic.com/2hhdw5y.jpg

Upvotes: 0

Views: 1160

Answers (2)

Christian Schnorr
Christian Schnorr

Reputation: 10786

Make the 'hidden part' a regular table view cell.

In heightForRowAtIndexPath, return the normal cell height for every cell, except for the hidden one. For this one, you will want to return either 0.0 (hidden) or some other value, when it is visible. You can store whether it's expanded or not in a bool property.

When it should expand, update the expanded property and call both [tableView beginUpdates]; and [tableView endUpdates];

This will show your previously hidden cell with a nice animation. You can also use this mechanism to hide it again.

Upvotes: 2

Jay Gajjar
Jay Gajjar

Reputation: 2741

You can use expandable tableview and design the tableview according to your needs.

https://github.com/OliverLetterer/UIExpandableTableView

Upvotes: 0

Related Questions