Iphone 滚动时禁用tableview单元格复选标记
当我滚动tabview单元格时,复选标记被隐藏。我该怎么办Iphone 滚动时禁用tableview单元格复选标记,iphone,Iphone,当我滚动tabview单元格时,复选标记被隐藏。我该怎么办 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [[tableView cellForRowAtIndexPath:indexPath] setSelected:NO]; FacebookFriend *friend = [self.fbFriendsFiltered object
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[[tableView cellForRowAtIndexPath:indexPath] setSelected:NO];
FacebookFriend *friend = [self.fbFriendsFiltered objectAtIndex:indexPath.row];
// Build list to invite
if ( [self.fbFriendsInvited containsObject:friend.fid] ) {
[self.fbFriendsInvited removeObject:friend.fid];
NSLog(@"fbFriendsInvited:%@",self.fbFriendsInvited);
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
} else {
//if ( [self.fbFriendsInvited count] >= kSelectionLimit )
// return;
[self.fbFriendsInvited addObject:friend.fid];
[[tableView cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
NSLog(@"fbFriendsInvited:%@",self.fbFriendsInvited);
}
}
您必须在
cellforrowatinexpath:
中添加一个条件签入,以便为以前选中的任何单元格设置复选标记。保留所选单元格的NSIndexPath
s数组/集合,并对其进行检查。您需要在cellForRowAtIndexPath中添加以下代码
NSArray *array = [cell subviews];
for (int i = 0; i < [array count]; i++)
{
if([[array objectAtIndex:i] isKindOfClass:[UIButton class]])
{
[[array objectAtIndex:i] removeFromSuperview];
}
}
不如你自己去实现它,然后如果需要的话,你可以寻求更多的帮助。
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}