开发者

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

开发者 https://www.devze.com 2023-01-15 07:48 出处:网络
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,

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

精彩评论

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