问题
When launching a UITabBarViewController from code in a storyboard the first view displays the navigation controller too high in the status area. Tapping the tabs corrects it, however the first view is incorrect. Do I need something else in the AppDelegate? Specific code solutions would be appreciated. Thanks
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Need something here???
return YES;
}
// initial UITabBarViewController in Storyboard
- (void)viewDidLoad {
[super viewDidLoad];
UITabBarItem * startTab = [[UITabBarItem alloc]initWithTitle:@"Home" image:[UIImage imageNamed:@"HomeTab.png"] tag:0];
UITabBarItem * helpTab = [[UITabBarItem alloc]initWithTitle:@"Help" image:[UIImage imageNamed:@"InfoDarkTab.png"] tag:1];
UIStoryboard * phone = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
StartListTVC *startVC = [phone instantiateViewControllerWithIdentifier:@"StartList"];
HelpWebVC * helpVC = [phone instantiateViewControllerWithIdentifier:@"HelpWeb"];
UINavigationController *startNavVC = [[UINavigationController alloc] initWithRootViewController: startVC];
UINavigationController *helpNavVC = [[UINavigationController alloc] initWithRootViewController: helpVC];
startNavVC.tabBarItem = startTab;
helpNavVC.tabBarItem = helpTab;
NSArray *myViewControllers = [[NSArray alloc] initWithObjects:
startNavVC,
helpNavVC];
[self setViewControllers:myViewControllers];
}
来源:https://stackoverflow.com/questions/58286874/uitabbarviewcontroller-navigation-item-in-displays-in-status-bar-area-on-launch