开发者

How to disable "delete" when the table section is 0 on iPhone?

I have a UITableView with tw开发者_开发知识库o sections, and I added a edit button. If I press the edit button, I can delete the item on the UITableView, but I wanna to check the if the section is 0, the delete button will not display, how can I handle it for that purpose? Thank you.


Implement the tableView:canEditRowAtIndexPath: method of the table view delegate in your view controller to check for the section. This and other edit methods control both edit and delete capabilities:

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0)
    {
        return NO;
    }

    return YES;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜