繁体   English   中英

UITableViewController-计数部分

[英]UITableViewController - count sections

在这种方法中-

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

我只想在有多个部分的情况下触发一种方法-在这里如何计算一个部分?

有一个委托方法numberOfSectionsInTableView,只需调用:

[self numberOfSectionsInTableView:tableView];

我不认为有一种方法可以防止调用此方法,但是如果您不希望使用标头,则可以返回nil

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if ([self numberOfSectionsInTableView:tableView] > 1){
        //Create your view and return it
    }else{
        return nil;
    }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM