[英]Does each screen in my Main.storyboard represent a scene in Swift?
[英]Swift ios7 storyboard - launch main scene myself
如果可能的话,我想控制哪些场景可以从A到Z看到。
我是iOS的新手,但是决定使用Storyboard,因为这似乎是事情发展的方向。
从我自己的角度来看,我将其视为在一个地方设计多个场景的工具,但我希望在自己的代码中控制过渡。 (我从已经可以自行管理和跟踪逻辑流的另一种语言和工具进行移植)
这引出了我的问题-我宁愿在启动时自行加载/选择第一个/主要场景,然后自己“启动”它。 我最好怎么做?
如果要首先显示任何视图控制器,则只需在情节提要中单击视图控制器,然后单击“是初始视图控制器”即可。
从代码(在AppDelegate中)
迅速
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
var storyboard = UIStoryboard(name: "Main", bundle: nil)
var initialViewController = storyboard.instantiateViewControllerWithIdentifier("LoginSignupVC") as! UIViewController
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
return true
}
目标C
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UIViewController *viewController = // determine the initial view controller here and instantiate it with [storyboard instantiateViewControllerWithIdentifier:<storyboard id>];
self.window.rootViewController = viewController;
[self.window makeKeyAndVisible];
return YES;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.