iPhone: Putting only one section of UITableView in Edit mode

a 夏天 提交于 2019-12-22 04:14:37

问题


I have three sections in my hypothetical UITableView. I'd like one section that is in editing mode. The rest of the sections to not be in editing mode. Is this possible at all?


回答1:


This really shouldn't be a mystery, as it's spelled out clearly in the documentation. Simply use the datasource method

- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath



回答2:


This worked great for me. In the example below section 0 is not editable whilst the other sections are.

override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
    if indexPath.section == 0{
        return false
    }
    return true
}


来源:https://stackoverflow.com/questions/579273/iphone-putting-only-one-section-of-uitableview-in-edit-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!