willSelectRowAtIndexPath Question
How do you add a second section (SECOND_SECTION) here to be excluded from selection when editing?
(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_SE开发者_StackOverflow社区CTION)) {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
rowToSelect = nil;
}
return rowToSelect;
}
it s being driving me nuts...
thanks
Since we know you’re concerned with editing behavior, look at the part that begins with if ((isEditing && …
. What comes after that will be evaluated only in editing mode. So, to add another section, you could change it like so:
if ((isEditing && (section == ONE_SECTION || section == SECOND_SECTION)) || (!isEditing && section != ONE_SECTION)) {
精彩评论