我在设置中将“启动屏幕文件”更改为我的“Main.Storyboard”。之前做这个应用程序运行良好,直接打开没有任何问题。但是在添加这个之后,在 Storyboard启动之前有一个黑屏。这是非常糟糕的用户体验。帮我解决这个问题。 AppDelegate 和 viewController 没什么大不了的。我在项目中有一个 LaunchScreen.xib,在图像 Assets 中也有 LaunchImage。我在项目中使用 Storyboard。我不想在我的应用程序中使用 launchScreen,我只想直接转到我的 Storyboard。
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.rootViewController = utilitiesObjet.getViewController("MainVC", mainStoryBoardName: "Main")
self.window?.makeKeyAndVisible()
Fabric.with([Crashlytics.self()])
return true
}
我通过添加 LaunchScreen.StoryBoard 来解决它,而不是使用 LaunchScreen.xib。谢谢大家:)
最佳答案
在应用程序中使用此代码将此代码委托(delegate)给 objective-c .....使用选项方法完成启动...
self.winow = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"<Your Storyboard name>" bundle:nil];
LoginViewController *ivc = [storyboard instantiateViewControllerWithIdentifier:@"<your view controller storyboard identifer name>"];
UINavigationController *navigationController=[[UINavigationController alloc] initWithRootViewController:ivc];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
对于 swift ....
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
// Override point for customization after application launch.
let storyboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let navigationController:UINavigationController = storyboard.instantiateInitialViewController() as UINavigationController
let rootViewController:UIViewController = storyboard.instantiateViewControllerWithIdentifier("VC") as UIViewController
navigationController.viewControllers = [rootViewController]
self.window?.rootViewController = navigationController
return true
}
关于ios - 应用程序在 iPhone 中以黑屏启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33085461/