以编程方式使用情节提要设置初始视图控制器如何以编程方式设置InitialViewController作为一个故事板?我想打开我的故事板,以一个不同的观点,取决于某些条件,可能会有所不同的发射,发射。
3 回答
12345678_0001
TA贡献1802条经验 获得超5个赞
Failed to instantiate the default view controller for UIMainStoryboardFile 'MainStoryboard' - perhaps the designated entry point is not set?
Info
Main storyboard file base name
General
Main Interface
application:didFinishLaunchingWithOptions:
- (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;}
慕姐4208626
TA贡献1852条经验 获得超7个赞
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) var exampleViewController: ExampleViewController = mainStoryboard.instantiateViewControllerWithIdentifier("ExampleController") as! ExampleViewController self.window?.rootViewController = exampleViewController self.window?.makeKeyAndVisible() return true}
ExampleViewController
创建一个具有当前窗口大小的新窗口,并将其设置为我们的主窗口 实例化一个故事板,我们可以使用它来创建新的初始视图控制器。 实例化我们的新的初始视图控制器,基于它的Storyboard ID 将新窗口的根视图控制器设置为我们刚刚启动的新控制器 使我们的新窗口可见
猛跑小猪
TA贡献1858条经验 获得超8个赞
(BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ if (shouldShowAnotherViewControllerAsRoot) { UIStoryboard *storyboard = self.window.rootViewController.storyboard; UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"rootNavigationController"]; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; } return YES;}
- 3 回答
- 0 关注
- 1067 浏览
添加回答
举报
0/150
提交
取消