问题
I have created a windows based project in XCode using IPhone as target platform and then I added a ViewController Sub Class. Now I want to make my newly added class to be shown at first screen. What is the proper way to achieve it?
Regards.
回答1:
Modify your appdelegate, you'll find something like this:
[window addSubview:myView];
[window makeKeyAndVisible];
Change my view to the view you want to show first.
回答2:
That is the correct way i found
first declare your view controller in appdelegate.h
SaveViewController *SaveController;
also
@property (nonatomic, retain) SaveViewController * SaveController;
then synthesize it in your appdelegate.m file
@synthesize SaveController;
now add the following lines of code in your application didFinishLaunching Method
SaveController = [[SaveViewController alloc]initWithNibName:@"SaveViewController" bundle:nil];
[window addSubview:[SaveController view]];
[self.window makeKeyAndVisible];
Thats all.. you are done :)
来源:https://stackoverflow.com/questions/6351510/how-to-set-my-own-viewcontroller-class-as-the-first-screen-root-view