开发者

Xcode 4 Universal Window Based App - Basic Query

I'm struggling getting started with the Universal App template in Xcode 4.1. I'm following the basic principles set out by kotancode here. The problem is getting the relevant view controller to load. I will focus on the iPhone part as an example. I create a subclass of UIViewController without a XIB as my "master" view controller class (where shared code will go). I then subclass this to create the iPhone specific UIViewController class called BaseViewCont开发者_运维问答roller_iPhone, this time with a XIB.

The iPhone specific app delegate the header is set to:

#import "TestAppDelegate.h"
#import "BaseViewController_iPhone.h"

@interface TestAppDelegate_iPhone : TestAppDelegate {
    BaseViewController_iPhone *viewController;
}
@property (nonatomic, retain) IBOutlet BaseViewController_iPhone *viewController;

@end

and for the implementation I try to override the applicationdidfinishlaunchingwithoptions method.

#import "TestAppDelegate_iPhone.h"

@implementation TestAppDelegate_iPhone

@synthesize viewController;

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];
    return YES;
}

-(void)dealloc {
    [viewController release];
    [super dealloc];
}

@end

This doesn't appear to work, it compiles fine and runs, but the new view controller and the corresponding XIB are not displayed (the original main window xib from the template is). I'm sure i'm missing something very simple, but i've spent a long time googling to no avail. Any help gratefully received.

Thank you.


  • Have you connected the ViewController in the app's delegate's XIB to your "BaseViewController_iPhone *viewController" ?

  • Are you sure the ViewController in the app's delegate's XIB is of the type BaseViewController?

  • Is the ViewController loading the correct XIB (check that in the app's delegate's xib)?

Check that and give some feedback.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜