我的应用程序中有 UITableView
。在那个表格中,单元格有标签。但是在 iOS 7
中,当我点击该行时它不会选择该行。但是,如果我用两根手指点击行,它就可以正常工作。它在 iOS 5.0
和 6.0
上运行良好。
我不使用任何手势识别器。
那是什么原因以及任何有解决此问题的想法的人。
我的委托(delegate)方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
NSString *cellIdentifier = [NSString stringWithFormat:@"RowIdentifier %i", indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
cell.backgroundView = [[UIView alloc] init];
[cell.backgroundView setBackgroundColor:[UIColor clearColor]];
[[[cell contentView] subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
width = tableView.frame.size.width;
[self createRow:cell :indexPath]; // This will add label to the content view
if (![self isSelectable:indexPath.row])
{
cell.userInteractionEnabled = NO;
} else
{
cell.userInteractionEnabled = YES;
}
for (id obj in cell.subviews)
{
if ([NSStringFromClass([obj class]) isEqualToString:@"UITableViewCellScrollView"])
{
UIScrollView *scroll = (UIScrollView *) obj;
scroll.delaysContentTouches = NO;
break;
}
}
[cell setExclusiveTouch:YES];
UIView * selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
[selectedBackgroundView setBackgroundColor:[UIColor colorWithRed:0.000 green:0.000 blue:1.000 alpha:1.000]];
[cell setSelectedBackgroundView:selectedBackgroundView];
return cell;
}
最佳答案
如果您的 View 中有任何手势识别器,例如 TapRecognizer,这可能会阻止手势到达您的表格单元格,解决方案是将您的手势识别器设置为:
[gestureRecognizer setCancelsTouchesInView:NO];
关于ios - 单击不选择 uitableview ios 7 中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20799592/