开发者

Create different RootViewController instances depending on the target

开发者 https://www.devze.com 2023-04-08 05:00 出处:网络
I want to instance the RootViewController with different objects depending 开发者_开发知识库on the target I\'m the running.

I want to instance the RootViewController with different objects depending 开发者_开发知识库on the target I'm the running.

For example,

I have 3 RootViewControllers (RVCBase, RVCA, RCB) and 4 targets (T1, T2, T3, T4). I want that whenever T1 is running, RVCA shows as the RootViewController; when T2 runs, RVCB; and when either T3 or T4 is running, the RCVBase shows.

Any help?

Thanks in advance.


Add define for exemple (T1, T2, T3, T4) with preprocessor macros. see build settings tab You can handle in code with:

#ifdef T1
//do something
#elif T2
//do something
#elif T3  
...
#endif


Use [self.window setRootViewController:rvca]; to set the RootViewController for the window.

You will have to set for the target and then pass in the RVC you want.

0

精彩评论

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

关注公众号