UIView frame when there is a navigation bar and a tab bar controller

I am creating a UIView programmatically in loadView . The application has a UITabBarController and a UINavigationController.

How to create a view that automatically resizes if there is a tab bar and navigation bar?

My current approach to this problem is to calculate the heights of the navigation controllers and the tab bar and subtract them from the height of the main screen:

float navObjectsHeight = self.tabBarController.tabBar.frame.size.height + self.navigationController.navigationBar.frame.size.height; CGRect mainFrame = CGRectMake(0, 0, screenFrame.size.width, screenFrame.size.height - navObjectsHeight); UIView *contentWrapper = [[UIView alloc] initWithFrame:mainFrame]; 
+6
objective-c iphone uiview uitabbarcontroller uinavigationcontroller
source share
1 answer

UIView has the ability to handle this situation. When you create it programmatically, the code you use is as follows:

 UIView *aView = [[UIView alloc] init]; aView.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
+5
source share

All Articles