简体   繁体   中英

My modal view controller didn't appeared on the screen. UITabbar + navigation app

UITabbar + navigation app. My modal controllerNav didn't appeared on the screen. What is wrong?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.window.rootViewController = self.tabBarController;

  if (isLoginScreenNeeded)
   {    
    LoginModalViewController *controller = [[[LoginModalViewController alloc] initWithNibName:@"LoginModal" bundle:[NSBundle mainBundle]] autorelease];

    UINavigationController *controllerNav = [[[UINavigationController alloc] initWithRootViewController:controller] autorelease];
    [self.window.rootViewController presentModalViewController:controllerNav animated:NO];
    }

  [self.window makeKeyAndVisible];
  return YES;
}

EDIT: @Zoleas, I updated my code. If I will remove [self.window makeKeyAndVisible]; - it works. But I don't understand why do I need to remove self.window makeKeyAndVisible];

just remove the parentViewController from the line [self.window.rootViewController.parentViewController presentModalViewController:controllerNav animated:NO];

the UITabBarController is the rootViewController so it probably doesn't have a parentViewController .

I have found that makeKeyAndVisible removes the Modal view from the parent so remove the line [self.window makeKeyAndVisible]; or you can move it to the top.

将您的main.xib文件视图映射到rootViewcontrollers视图..然后它将起作用

使用以下代码进行映射

[map from:kAppViewController toModalViewController:[controller class]];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM