我的应用程序中有UITableView
。在该表中,单元格具有标签。但是iOS 7
当我点击该行时,它不会选择该行。但是如果我用两根手指点击行,它可以正常工作。它在iOS 5.0
和6.0
上工作正常。
我不使用任何手势识别器。
这是什么原因,任何有任何想法来解决这个问题的人。
我的委托方法
- (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;
}
如果视图中有任何手势识别器(如 TapRecognizer),这可能会阻止手势到达表格单元格,则解决方案是将手势识别器设置为:
[手势识别器设置取消触摸在视图:否];