willSelectRowAtIndexPath问题

时间:2011-01-09 14:46:20

标签: iphone objective-c cocoa-touch uitableview

如何在此处添加第二部分(SECOND_SECTION)以在编辑时从选择中排除?

 (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath {
 NSIndexPath *rowToSelect = indexPath;
    NSInteger section = indexPath.section;
    BOOL isEditing = self.editing;
    // If editing, don't allow notes to be selected
    // Not editing: Only allow notes to be selected
    if ((isEditing && section == ONE_SECTION) || (!isEditing && section != ONE_SECTION)) {
  [tableView deselectRowAtIndexPath:indexPath animated:YES];
  rowToSelect = nil;

    }

 return rowToSelect;
}
这让我疯了......

感谢

1 个答案:

答案 0 :(得分:0)

由于我们知道您关注编辑行为,请查看以if ((isEditing && …开头的部分。之后的内容仅在编辑模式下进行评估。因此,要添加另一个部分,您可以像这样更改它:

    if ((isEditing && (section == ONE_SECTION || section == SECOND_SECTION)) || (!isEditing && section != ONE_SECTION)) {