Objective c iOS UIWebView setUserInteractionEnabled为否不适用于iOS 6
我将UIWebView作为UITableView中的单元格。我知道这是不推荐的,但是WebView没有滚动,所以推荐并不重要。我使用web视图来设置单元格的样式和主题 我遇到的问题是,在iOS 6中,当我将userInteractionEnabled设置为NO时,UIWebView不会向响应程序链传递触动事件。表视图从不调用didSelectRowAtIndexPath。我应该注意到,这在iOS 5中运行良好 我的问题是,苹果是否改变了UIWebView处理userInteractionEnabled的方式 任何评论都会有所帮助 这是我打电话的地方。在正确的单元格实例上调用它(我在表中只有1个WebView单元格) 在iOS 6中运行良好Objective c iOS UIWebView setUserInteractionEnabled为否不适用于iOS 6,objective-c,uitableview,ios6,uiwebview,Objective C,Uitableview,Ios6,Uiwebview,我将UIWebView作为UITableView中的单元格。我知道这是不推荐的,但是WebView没有滚动,所以推荐并不重要。我使用web视图来设置单元格的样式和主题 我遇到的问题是,在iOS 6中,当我将userInteractionEnabled设置为NO时,UIWebView不会向响应程序链传递触动事件。表视图从不调用didSelectRowAtIndexPath。我应该注意到,这在iOS 5中运行良好 我的问题是,苹果是否改变了UIWebView处理userInteractionEnab
- (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;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
静态NSString*CellIdentifier=@“Cell”;
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:CellIdentifier];
}
UIWebView*wv=[[UIWebView alloc]initWithFrame:CGRectMake(0,0,cell.contentView.frame.size.width,cell.contentView.frame.size.height)];
NSString*html=@;
[wv loadHTMLString:html baseURL:nil];
wv.userInteractionEnabled=否;
[[cell contentView]addSubview:wv];
返回单元;
}
我的问题与userInteractionEnabled无关
这是因为我还重写了shouldHighlightRowatingIndexPath:方法
- (BOOL) tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return NO;
}
return YES;
}
在iOs 6中,这似乎会在该节点禁用对单元格的触摸事件。很高兴知道。您是将webView添加到cell还是cell.contentView?我使用的是自定义类@接口WebViewTableCell:UIWebView在tableView数据源方法中构建单元格时,将其作为子视图附加到何处?不需要子类化..我还需要子类化。看起来唯一的区别是将其添加到contentview。我想知道是不是因为我的手机没有superview,触控事件被抛出。我将看看实现类似的东西是否能解决我的问题。谢谢。如果您想使用自定义单元格大小,您需要在tableView willDisplayCell方法中调整webview的大小。
- (BOOL) tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
return NO;
}
return YES;
}