【发布时间】:2013-12-27 11:06:54
【问题描述】:
我的应用中有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;
}
【问题讨论】:
-
显示您的 tableview 委托和数据源方法。
-
是的,展示你的方法。
-
您是否在视图中添加任何手势识别器
-
加上我的声音,我和 OP 有同样的错误。如果你知道了,可以告诉我吗?
-
我也有这个问题。
标签: ios ios6 uitableview ios7