我有一個奇怪的uitableview選擇問題。試圖在預先選擇一對單元格的情況下使用多個選擇。多項選擇設置爲true。UITableView選擇 - 多選
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
cell.textLabel.font = [UIFont systemFontOfSize: 15.0f];
cell.textLabel.text = [data objectAtIndex:indexPath.row];
// if([_selectedInts containsObject:[NSNumber numberWithInt:(int)indexPath.row]]){
//
// [cell setSelected:YES animated:NO];
//
// } else {
//
// [cell setSelected:NO animated:NO];
//
// }
return cell;
}
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
cell.selectionStyle = UITableViewCellSelectionStyleGray;
[cell setUserInteractionEnabled:YES];
if([_selectedInts containsObject:[NSNumber numberWithInt:(int)indexPath.row]]){
[cell setSelected:YES animated:YES];
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
} else {
[cell setSelected:NO animated:YES];
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
}
當tableview加載一堆單元格時,由於標記需要選擇的索引的整數列表而被選中。
這些單元格停止響應,不會在獲取tapped時發出didselect和diddeselect方法。
什麼問題?
真棒!非常感謝 – stackOverFlew