当UITableView 在编辑状态时,点击cell,不调用didSelectedRowAtIndexPath解决办法
2016-11-01 08:12
435 查看
当UITableView 在编辑状态时,点击cell,不调用didSelectedRowAtIndexPath.
问题代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.tableView.editing == YES) {
NSLog(@"now in editing mode");
}
else {
NSLog(@"now in normal mode");
}
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
// must be called first according to Apple docs
[self.tableView setEditing:editing animated:animated];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
以上代码编辑状态下点击cell,无法调用-didSelectedRowAtIndexPath方法打印"now
in editing mode"。
解决方法:
将UITableVIew 的属性 allowsSelectionDuringEdinting 设置为 TRUE,之后就可在编辑模式下,调用点击方法了。
self.tableView.allowsSelectionDuringEditing=YES;
问题代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.tableView.editing == YES) {
NSLog(@"now in editing mode");
}
else {
NSLog(@"now in normal mode");
}
}
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
[super setEditing:editing animated:animated];
// must be called first according to Apple docs
[self.tableView setEditing:editing animated:animated];
}
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
// Return NO if you do not want the specified item to be editable.
return YES;
}
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellEditingStyleNone;
}
- (BOOL)tableView:(UITableView *)tableView shouldIndentWhileEditingRowAtIndexPath:(NSIndexPath *)indexPath {
return NO;
}
以上代码编辑状态下点击cell,无法调用-didSelectedRowAtIndexPath方法打印"now
in editing mode"。
解决方法:
将UITableVIew 的属性 allowsSelectionDuringEdinting 设置为 TRUE,之后就可在编辑模式下,调用点击方法了。
self.tableView.allowsSelectionDuringEditing=YES;
相关文章推荐
- UITableView进阶:在编辑状态时修改cell
- UITableView实现选择框和编辑状态时cell向右移动的自定义方法
- tableview编辑状态下 默认选中cell之后 无法点击取消
- UITableView编辑模式可以点击Cell
- UITableView DeleteControl ---- 响应UITableView编辑状态点击deleteControl的事件
- UITableView实现选择框和编辑状态时cell向右移动的自定义方法
- ios 8 UITableView 编辑删除状态不点击“删除”,页面假死临时解决方案
- UITableView Cell 点击时的带颜色背景效果,而不是选中颜色效果
- uitableview取消cell选中状态关于deselectRowAtIndexPath
- 点击UITableView的cell展开收缩
- ios UITableView 点击cell后返回正常背景
- iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
- UITableView中Cell点击展开方法
- 禁止编辑UITableView的Cell
- tableview 编辑状态下,UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert 多选的时候,替换圆圈图片
- UITableView指定Cell的点击区域
- UITableView 的Cell取消高亮状态
- 点击UITableView的cell展开收缩
- UITableView,根据indexPath设置cell的编辑样式,删除cell ,增加cell &搜索条
- UITableView获取cell的row值(解决自定义cell里的button通过点击无法获得cell的indexpath的问题)