开发者

iOS: How to group controls on screen, like in Settings?

My app needs a screen with several controls, such as a slider and a few switches. These controls will be used frequently, so I don't want to put them in a Settings bundle.

However, I like the way the controls are grouped in Settings and would like to do the same on this 'control' screen.

Obviously, Settings uses a table view controller in 'group' mode. Ideally, I'd like to lay out this view in Interface Builder, but I'll be darned if I can figure out how.

Do I need to set up this page programmatically, or is there a trick th开发者_Go百科at will let me do this in IB?

TIA: John


What I do, is in my XIB file, I create my individual cells in design view, set up outlets for them, and then in the code of my data source, I will connect those cells to the table.

something like:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSInteger row = [indexPath row];
    NSInteger section = [indexPath section];
        if(section == 0){
            if(row == 0){
                return basicCell;
            }
            if(row == 1){
                return linkedCell;
            }
            if (row == 2) {
                return tipsCell;
            }
        }
        if(section == 1){
            return wifiCell;
        }
        if(section == 2){
            return loginCell;
        }
    return nil;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜