开发者

XCode 4.01 iOS Universal App not showing iPad View

I am creating a Universal App with XCode support (no unit tests) using XCode 4.01.

In the iPhone folder I create a new UIViewController called iPhoneViewController with XIB.

In xxxAppDelegate_iPhone.h I create a iPhoneViewController instance (called viewController), outlet and property. In the .m I synthesize the property.

In the xxxAppDelegate_iPhone.m I add the following code:

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

    // Override point for customization after application launch.
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

In IB I open MainWindow_iPhone and add a new View Controller. I set the view controller class to be iPhoneViewController and type in the XIB name. I hook up the outlet to the app delegate.

Running the app in Simulator for iPhone - everything works exactly as it is supposed to.


Now I add the same type of thing for iPad:

In the iPad folder I create a new UIViewController called iPadViewController with XIB.

In xxxAppDelegate_iPad.h I create a iPadViewController instance (called viewController), outlet and property. In the .m I synthesize the property.

In the xxxAppDelegate_iPad.m I add the following code:

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

    // Override point for customization after application launch.
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    return YES;
}

In IB I open MainWindow_iPad and add a new View Controller. I set the view controller class to be iPadViewController and type in the XIB name. I hook up the outlet to the app delegate.

Running the app in Simulator for iPad - the default MainWindow_iPad content is displayed but NOT the new view I added.

I have done this several times - always with the same result.

Debugging:

Setting a breakpoint here in the iPad code:

[self.window addSubview:viewController.view];

viewController is NIL and is never getting loaded.

If I progr开发者_运维问答ammatically load from the XIB I can get it to display but it does not fill the entire view.

What am I doing wrong?


You also need to connect the window property in IB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜