我有一个UIWebView作为UITableView中的单元格。我知道不推荐这样做,但是WebView没有滚动,所以这个建议无关紧要。我使用web视图来设置单元格的样式和主题。
我遇到的问题是,在iOS 6中,当我将userInteractionEnabled设置为NO时,UIWebView不会将触摸事件传递到响应器链上。表视图从不调用didSelectRowAtIndexPath。我要指出的是,这在iOS 5中工作得很好。
我的问题是,苹果是否改变了UIWebView处理userInteractionEnabled的方式?
任何评论都会有所帮助。
这是我打电话的地方。它是在正确的单元实例上调用的(我在表中只有一个WebView单元)
webView.userInteractionEnabled = NO;发布于 2013-03-01 00:14:12
在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-03-01 02:42:22
我的问题与userInteractionEnabled无关。
这是因为我还覆盖了shouldHighlightRowAtIndexPath:方法
- (BOOL) tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return NO;
}
return YES;
}在iOS6中,这似乎禁用了对该indexPath上的细胞的触摸事件。很高兴知道。
https://stackoverflow.com/questions/15139875
复制相似问题