UITableviewCell
除了一个中的一个以外,一个如何禁用所有内容的选择UITableview
。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// Deselect row
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// NSLog(@"Row Selected = %li",(long)indexPath.row);
self.selectedInvitedUserId = [[self.viewOrderUserArray valueForKey:@"InvitedUserId"] objectAtIndex:[indexPath row]];
NSLog(@"Row selectedInvitedUserId = %@",self.selectedInvitedUserId);
if( self.selectedInvitedUserId && [indexPath row] != 0 )
{
if ([[self.viewSelectedItemsArray lastObject] count] == 0)
{
[self performSegueWithIdentifier:@"delimenuFromViewOrderList" sender:self];
}
else
{
[self performSegueWithIdentifier:@"viewOrderSummaryFromOrderDetails" sender:self];
}
}
}
我知道这会禁用所有单元格。
cell.selectionStyle = UITableViewCellSelectionStyleNone;
您需要在
(UITableViewCell *)tableView:cellForRowAtIndexPath:
打回来。这是在点击时将执行的单元格上的设置。这不是您应该尝试手动管理的东西
像这样:
// Where indexPath != 0 points to the row you want to enable
if( self.selectedInvitedUserId && indexPath != 0 )
{
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
else
{
[cell setSelectionStyle:UITableViewCellSelectionStyleBlue];
}
笔记
这只会停止突出显示它。您将需要在didSelectRowAtIndexPath:
回调内部检查回调是否正确。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句