2017-06-01 95 views
-1

我以编程方式创建UIWebView并在UIWebView中加载url。但问题是我在后台显示tableview和它显示的表格视图:iOS:在后台显示视图的UIWebView

enter image description here 正如你所看到的,你可以在后台看到tableview的行。

我试图改变背景颜色:

self.backgroundColor = [UIColor whiteColor]; 
self.opaque = YES; 

但它并没有改变任何事情。

这里是我如何加载的UIWebView:

// MywebView is subclass of UIWebView 
-(void)loadWebView 
{ 
    self.web = [[MywebView alloc] initWithFrame:self.view.frame]; 
    [self.view addSubview:self.web]; 
    [self.view bringSubviewToFront:self.web]; 
    self.web.MywebViewdelegate = self; 

} 

任何你知道为什么被显示在背景中的tableview?

我真的很感谢你的帮助。

+1

它看起来像表视图顶部?尝试'parent.bringSubviewToFront(yourWebView)' – hola

+0

您是否可以点击页面中的文本框或按钮? – ozgur

+0

@hola,我带了UIWebView。 – user2924482

回答

0

您可以使用Instrumentation在应用程序中查找视图的层次结构。最有可能的是yourTableView在最上面。 使用[self.view bringSubviewToFront:webview]和[self.view sendSubviewToBack:webview]将webview分别放在前面和后面。

-1

我不知道MyWebView类实现的是什么。但我马肯定地通知你,如果你这样做的背景将是好的

- (void)loadWebView 
{ 
    UIView *view = [[UIView alloc]initWithFrame:self.view.bounds]; 
    view.backgroundColor = [UIColor whiteColor]; 
    self.web = [[MywebView alloc] initWithFrame:self.view.frame]; 
    [view addSubview:self.web]; 
    [self.view addSubview:view]; 
    self.web.MywebViewdelegate = self; 
}