我正在建立在我的UITableViewController 8个细胞。我想知道我怎么能显示在第4,8单元的披露指标。现在我建立它在

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

虽然我深知这是要披露指示器添加到每个细胞

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
有帮助吗?

解决方案

使用if语句的简单:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    ... // do whatever
    UITableViewCellAccessoryType accessoryType = UITableViewCellAccessoryNone;
    if (indexPath.row == 3 || indexPath.row == 7) {
        accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.accessoryType = accessoryType;
    ... // do whatever
}

其他提示

您知道indexPath,所以为什么不只是有条件地适用披露指标时

if((indexPath.row == 3) || (indexPath.row == 7))

(indexPath.row是以0当然...第四是3和8号是7,您应使用#define语句或其他方式来保持幻数出来的有太多。)

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top