2015-09-11 136 views
0

UITableViewController正在加载多重选择模式并且ON编辑模式。在编辑模式下选择了UITableViewCell

- (void) viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:YES]; 

.... 

    [self.tableView setEditing:YES animated:YES]; 
    self.tableView.allowsMultipleSelectionDuringEditing = YES; 

} 

结果是这样的一个: enter image description here

然而,这并不是我所期待的,因为我想已经被选中后viewWillAppear中的一些细胞。

我想是这样

enter image description here

我需要在- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath什么代码???

我需要其他方法的代码吗?

+0

这个好运气吗? – Miknash

回答

0

你必须跟踪选定的,你的模型可能是BOOL变量,indexPathsNSArray,或其中的任何东西。

所以,你应该在你cellForRowAtIndexPath做什么:

if(dataModel.shouldBeSelected == true){ 
    cell.imageView.image = [UIImage imageNamed:@"selected"]; 
} 
else{ 
    cell.imageView.image = [UIImage imageNamed:@"empty"]; 
} 

注意,你必须采取非选定的照顾,让您可以防止选定单元格的重用,并显示不正确的结果。

相关问题