ios - 单击不选择 uitableview ios 7 中的行

标签 ios ios6 uitableview ios7

我的应用程序中有 UITableView。在那个表格中,单元格有标签。但是在 iOS 7 中,当我点击该行时它不会选择该行。但是,如果我用两根手指点击行,它就可以正常工作。它在 iOS 5.06.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/

相关文章:

iphone - 在 IOS 中隐藏状态栏时显示网络事件指示器

ios - 删除 UItableview 单元格 segue 按钮?

UITableView 快速获取 titleForHeadersInSection

iphone - UISearchView 不显示搜索值

ios - 不懂全局变量

c# - UITableView reloadData 重复单元格

ios - 是否可以使用 iOS 6 实现 3D map View

在 Xcode 4.5 中开发的 iOS 应用程序在 iOS 6 上运行良好,但在 iOS 5 上崩溃

iphone - 手势识别器,奇怪的行为(乘数效应)iOS

ios - 如何跟踪变量在哪一点被更改?