The tab bar shifts down outside the simulator

I created an empty project (Xcode 4.2 iOS SDK 5), I added a new view to it and make it the root view controller inside appDelegate, so when I launch the application it displays this view correctly, however, I added a tabbar control for the view, created an IBOutlet for him in the newly created view and added this line to the viewDidLoad method of the view:

[self.view addSubview:self.tabController.view]; 

so that the tab bar loads correctly in the iphone simulator, but with a small problem that I could not fix: half of this tab bar moves down the simulator, which prevents the tabs from appearing, just like in the following screenshot

screenshot

How can I fix this problem?

0
source share
2 answers

This is most likely due to the status bar. But, since the subview where you insert the controller can be of any size, the most universal solution is:

 [tabController.view setFrame:self.view.bounds]; 

(assuming self.view is the view where you add it)

+2
source

The view with the tab bar at 480px is high, but the view you add is smaller than the status bar. This means that it starts 22px too low and ends 22px too low - at the bottom of the screen.

If you want the tab bar to be global for the link to the application in IBOutlet on the applicationโ€™s directory, do this in the didFinishLaunching method:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // ... // Add the tab bar controller view to the window and display. [window addSubview:tabController.view]; [window makeKeyAndVisible]; return YES; } 

This adds it to the main window, and not to another view. This will snap to the top of the screen, so the bottom will be at the bottom of the screen.

+1
source

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


All Articles