UITableCell使用默认样式设置CheckMark后不居中对齐的问题

没有测过各个ios版本的兼容性:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    cell.textLabel.text = ...;
    if (/* your condition */) {
        cell.accessoryType = UITableViewCellAccessoryCheckmark;
        cell.indentationLevel = 4;
    } else {
        cell.accessoryType = UITableViewCellAccessoryNone;
        cell.indentationLevel = 0;
    }
    return cell;
}

 

Leave a Reply

Your email address will not be published.