Tom*_*Tom 1 storyboard scene viewcontroller ios swift
如果可能的话,我想控制自己从A到Z可见的场景.
我是iOS的新手,但决定使用故事板,因为它似乎是事情的方向.
从我自己的角度来看,我将把它视为在一个地方设计多个场景的工具,但我想用我自己的代码控制转换.(我正在移植另一种已经管理和跟踪逻辑流程本身的语言和工具)
这引出了我的问题 - 我宁愿在启动时自己加载/选择我的第一个/主要场景并自己"启动"它.我该如何做到最好?
如果你想让任何视图控制器首先显示,那么只需在故事板中单击你的视图控制器,然后单击是初始视图控制器
从代码(在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
}
Run Code Online (Sandbox Code Playgroud)
目标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;
}
Run Code Online (Sandbox Code Playgroud)