1

我有一个 UIWebView 作为 UITableView 中的一个单元格。我知道这是不推荐的,但 WebView 不滚动,所以推荐无关紧要。我使用 web 视图来设置单元格的样式和主题。

我遇到的问题是,在 iOS 6 中,当我将 userInteractionEnabled 设置为 NO 时,UIWebView 不会将触摸事件传递给响应者链。表视图从不调用 didSelectRowAtIndexPath。我应该注意到这在 iOS 5 中运行良好。

我的问题是,Apple 是否改变了 UIWebView 处理 userInteractionEnabled 的方式?

任何评论都会有所帮助。

这是我打电话的地方。它在正确的单元格实例上被调用(我在表中只有 1 个 WebView 单元格)

webView.userInteractionEnabled = NO;
4

2 回答 2

2

在 iOS 6 中运行良好

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }

    UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, cell.contentView.frame.size.width, cell.contentView.frame.size.height)];
    NSString *html = @"<div></div>";
    [wv loadHTMLString:html baseURL:nil];
    wv.userInteractionEnabled = NO;
    [[cell contentView] addSubview:wv];

    return cell;
}
于 2013-02-28T16:14:11.533 回答
0

我的问题与 userInteractionEnabled 无关。

这是因为我还覆盖了 shouldHighlightRowAtIndexPath: 方法

- (BOOL) tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.section == 0) {
        return NO;
    }
    return YES;
}

并且似乎在 iOs 6 中,这会禁用该 indexPath 处的单元格的触摸事件。很高兴知道。

于 2013-02-28T18:42:22.073 回答