How to set my own ViewController class as the first screen (root view)

妖精的绣舞 提交于 2019-12-25 01:38:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!