Programmatically setting content to fill the screen between the tab bar and the navigation controller

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 webview is defined programmatically, and I initialized it with a frame, as shown below.

I managed to get the desired behavior by hard coding in some values, but I saw that this does not work on all devices. In particular, it seems that different OSs can consider (0,0) as different points on the screen (the upper left corner of the screen for some, and the upper left corner more under the navigation bar for others).

My question is: how to set the position and size of the web view to fill the screen on all devices? And can anyone explain why this is not behaving the way I think it should be?

//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)]; 
0
source share

Source: https://habr.com/ru/post/978768/


All Articles