What's the best way to combine multiple开发者_如何转开发 styles into one UITableView?
For instance, in the iTunes Music Store App (Music tab), there's ads on top, then large rounded table cells, and then Grouped-styled table cells, etc. I'm looking to have a custom view cell on top, then several rows of Grouped-style table cells, and then several rows of Plain-styled table cells.
I'm currently initializing my UITableView with UITableViewStyleGrouped, which works well for my need of Grouped-style cells, but I can't find a good way of overwriting the individual cells' styles so that I can create the other styled cells.
Any suggestions?
You're talking about the table style (one has cells that are full width of the view. Other has lines background and rounded corners on sections).
You could probably hack something together by using a scroll view and 2 embedded table views with their scrolling disabled, but I wouldn't recommend it. You're not supposed to put table views in scroll views and it won't be very Appley and HIGy - prepare yourself for headaches.
You might want to consider rethinking your view structure.
A couple things: You can set UITableView
's tableHeaderView
and tableFooterView
properties to custom views to get most of the way towards the iTunes Music Store app screen you're talking about. The rest is just returning different UITableViewCell
types depending on which section you're in:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
switch (indexPath.section) {
case 0:
// return a cell with the first section's style
break;
case 1:
// return a cell with the second section's style
break;
}
}
精彩评论