UIWebBrowserView不会跨越整个UIWebView

Vol*_*ron 6 iphone layout uiwebview ios

所以我一直试图让这个简单的行为在我的iPhone应用程序上运行一段时间.我的顶部有一个导航栏,底部有一个标签栏.我正在webview中加载我的所有内容,我想在两者之间加入.我已经两次发布过这个问题,

这两个:IOS View仍然没有加载到正确的位置

在这里:以编程方式设置内容以填充标签栏和导航控制器之间的屏幕

目前,我的webview看起来并且在iPhone 4和4s上运行良好,问题出现在5s.当屏幕完成加载时,它看起来像这里的图像:http://grosh.co/screen.jpg.这在模拟器和设备上都会发生.

经过进一步检查,我发现UIWebView实际上正确地跨越了(你看到的灰色区域是webview).较小的内容实际上是一个UIWebBrowserView,我很难找到任何信息.

我有我在下面使用的代码,以及日志输出,以确保所有数字都正确.我的问题是,

1)是否有更好的方法将webview设置为跨越所有设备的顶部和底部条之间的屏幕区域?

2)如果没有,有没有办法将UIWebBrowser设置为跨越整个webview?

我尝试迭代webview的子视图,如下所述:http://normansoven.com/ios-webview/#.VHyOUr6Jnww但从未见过webBrowserView.

Teh Codez:

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.    


CGFloat viewheight = self.view.bounds.size.height;
NSLog(@"Height1:%f",viewheight);

CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat viewheight2 = screenRect.size.height;
NSLog(@"Height2:%f",viewheight2);

CGFloat height = self.view.frame.size.height;
NSLog(@"Height3:%f",height);


CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height;
NSLog(@"NAVHeight:%f",navBarHeight);

CGFloat tabBarHeight = self.tabBarController.tabBar.frame.size.height;
NSLog(@"TABHeight:%f",tabBarHeight);

CGFloat statusbarheight = [UIApplication sharedApplication].statusBarFrame.size.height;
NSLog(@"StatbarHeight:%f",statusbarheight);

CGFloat spaceToRemove = navBarHeight + tabBarHeight + statusbarheight;
    NSLog(@"NAVHeight+TABHeight:%f",spaceToRemove);
CGFloat newHeight = viewheight - spaceToRemove;
        NSLog(@"NewHeight:%f",newHeight);

CGRect frame =  CGRectMake(0 , navBarHeight + statusbarheight, self.view.frame.size.width, newHeight);

self.webView = [[UIWebView alloc]initWithFrame:frame];


//self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];


[self.view addSubview:self.webView];

self.webView.scalesPageToFit = true;
NSURL *url = [NSURL URLWithString:@"http://example.com/finnaRoot/index.php"];
NSURLRequest *requestURL = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:requestURL];
self.webView.scrollView.showsVerticalScrollIndicator = false;


self.navigationItem.titleView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo.png"]];

self.webView.delegate = self;
self.tabBarController.delegate = self;
self.webView.scrollView.delegate = self;

}
Run Code Online (Sandbox Code Playgroud)

来自iPhone 5s的日志输出

2014-11-26 17:19:21.184 Finna[14617:1765689] Height1:568.000000
2014-11-26 17:19:21.185 Finna[14617:1765689] Height2:568.000000
2014-11-26 17:19:21.185 Finna[14617:1765689] Height3:568.000000
2014-11-26 17:19:21.185 Finna[14617:1765689] NAVHeight:44.000000
2014-11-26 17:19:21.185 Finna[14617:1765689] TABHeight:49.000000
2014-11-26 17:19:21.185 Finna[14617:1765689] StatbarHeight:20.000000
2014-11-26 17:19:21.185 Finna[14617:1765689] NAVHeight+TABHeight:113.000000
2014-11-26 17:19:21.186 Finna[14617:1765689] NewHeight:455.000000
Run Code Online (Sandbox Code Playgroud)

ily*_*lya 8

我遇到过同样的问题.并找到了简单的修复.罪魁祸首是UIViewController财产automaticallyAdjustsScrollViewInsets.UIViewController参考说:

默认值为YES,允许视图控制器调整其滚动视图插入以响应状态栏,导航栏和工具栏或标签栏消耗的屏幕区域.

这意味着即使您正确设置了webview框架或添加了autolayout约束,也会UIViewController将顶部间隙添加到UIWebView滚动视图中.要克服这种行为

NO如果要自行管理滚动视图插入调整,则设置为,例如视图层次结构中有多个滚动视图时.

在我们的上下文中"管理滚动视图插入调整你的自我"意味着我们不会添加任何插入;)

任何滚动视图都存在同样的问题,即iOS 10中UITextView顶部的空白区域 https://stackoverflow.com/search?q=automaticallyAdjustsScrollViewInsets