问题
I have a UIwebview that I want to fill the screen between the navigation bar at the top and the tab bar at the bottom. My web view is being defined programmatically and I was initializing it with a frame as below.
I have been able to get the desired behavior by hard coding in some values, but I have seen that this does not work across all devices. Specifically, it seems that different OS's might consider (0,0) as different points on the screen (the top left corner of the screen for some, and the top left most corner under the nav bar for others).
My question is, how do I set the web view position and size to fill the screen across all devices? And can anyone explain why this doesn't behave as I think it ought to?
//iphone 5s running iOS 8
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight+20)];
//iphone 5 running iOS 7
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 64, screenWidth, screenHeight-93)];
//what i thought would work for all, but doesnt fill the height of the screen...
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, screenWidth, screenHeight)];
来源:https://stackoverflow.com/questions/26773155/programmatically-setting-content-to-fill-screen-between-tab-bar-and-nav-controll