我需要在didSelectRowAtIndexPath
按钮的moveRowAtIndexPath
和UITableView
方法之间进行检测,但我发现当我在[myTableView setEditing:YES animated:YES]
设置ViewDidLoad
时,我是否选择或者继续将单元格移动到moveRowAtIndexPath
。我真的想要检测两种方法,以便在敲击或移动细胞时进行不同的治疗。
这是我的代码:
- (void)viewDidLoad {
[super viewDidLoad];
[HomeTableView setEditing:YES animated:YES];
[HomeTableView setScrollEnabled:NO];
}
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
//it's always get here when i select on cell
//do something here
}
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 0) // Don't move the first row
{
return NO;
}
return YES;
}
-(BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
return YES;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//i wanna do thing here but it's never into this method when i set [HomeTableView setEditing:YES animated:YES];
}
任何帮助都是值得的。提前谢谢......
答案 0 :(得分:1)
您需要将UITableView的allowsSelectionDuringEditing属性设置为true ..
self.tableView.allowsSelectionDuringEditing=YES;
答案 1 :(得分:0)
UITableView
上有一个属性,允许在编辑模式下选择行。您可以在storyboard
至Single Selection During Editing
或代码中将allowsSelectionDuringEditing
属性设置为YES
。