UITableViewController正在加载多选和 ON EDIT 模式。
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
....
[self.tableView setEditing:YES animated:YES];
self.tableView.allowsMultipleSelectionDuringEditing = YES;
}
然而,这不是我想要的,因为我想在viewWillAppear之后选择一些单元格。
我想成为这样的
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
???
我是否需要其他任何方法的代码?
答案 0 :(得分:0)
您必须跟踪选定的内容,模型中可能是BOOL
变量,NSArray
中的indexPaths
或其间的任何内容。
那么你应该对你做些什么cellForRowAtIndexPath
:
if( dataModel.shouldBeSelected == true){
cell.imageView.image = [UIImage imageNamed:@"selected"];
}
else{
cell.imageView.image = [UIImage imageNamed:@"empty"];
}
请注意,您必须处理未选择的单元格,以防止重复使用所选单元格并显示不正确的结果。