I am creating a UIView programatically in loadView. The application has a UITabBarController and UINavigationController.
How do I create a view that automatically resizes when a tab bar and a navigation bar both exist?
My current approach to this problem is calculating the heights of the navigation and tab bar controllers and subtracting them from the mainScreen's height:
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];
The UIView has a property to handle that situation. As you are creating it programatically the code to use is:
UIView *aView = [[UIView alloc] init];
aView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With