开发者

Table View Groups on iPad

I was followed this tutorial (iPad Hello World) and was wondering if it would be possible to group items together on the table view. Basically, when the user opens the app the table view would say something like: Group 1, Group 2, a开发者_高级运维nd Group 3. When the user tabs on one group the table view would load the items in the group.


There's a lot to do in order to get this, I'll recommend you to read this UITableView programming guide in order to fully comprehend this element (But if you want to go pretty straight forward, go to "Navigating a Data Hierarchy With Table Views" section). But this is a brief of what you'll be doing besides to that tutorial you mention:

First you'll need to model your data set (extended NSObject classes, container clases with NSArrays or NSMutableArrays or even single NSObjects to construct your hierarchy). Once you have these. Then you'll implement the method

numberOfSectionsInTableView:

from the UITableViewDataSource protocol. Providing to it the number of elements on you top level object of your hierachy.

Then in this table delegate, you'll have to implement the method

tableView:didSelectRowAtIndexPath:

and again, push a new view for that selected row, get the data from your model and populate the pushed view with this data.

Hope this is useful dude!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜