当我的应用程序在iPad上运行时,我想为根视图加载其他.xib。我试图从下面的代码中看到,但是发生的是线程进入了正确的if语句,因此它可以识别出它是iPad,但是当视图加载时它会加载视图的iPhone版本。

这是我的代码,我试图在应用程序委托中决定为rootView加载哪个笔尖:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    //Add status bar
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];


    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        self.window.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewControlleriPad" bundle:nil];
    } else {
        self.window.rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
    }


    self.window.rootViewController = self.navigationController; //Adds RootViewController to the NavigationController interface
    self.navigationController.navigationBar.titleTextAttributes =  @{NSForegroundColorAttributeName : [UIColor whiteColor]}; // navigation titles
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; // navigation buttons

最佳答案

您需要重做此行:

self.window.rootViewController = self.navigationController; //Adds RootViewController to the NavigationController interface


这就是使您的结果变得愚蠢的原因。

10-07 19:44
查看更多