ios - 应用程序在 iPhone 中以黑屏启动

标签 ios objective-c iphone swift

我在设置中将“启动屏幕文件”更改为我的“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
    }

enter image description here

我通过添加 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/

相关文章:

ios - 如何在 Ios 中添加 customView xib 作为注释?

iphone - 如何比较两个对象是否真的是同一个对象?

objective-c - 在 Objective-C 中创建常量的最佳方法是什么

iPhone自定义浏览器应用程序以编程方式在主屏幕上创建 'Bookmark'

iphone - 为什么 UIScrollView 不弹跳?

android - 如何修复 - 使用 lowerCamelCase 命名非常量标识符

ios - 自定义 segue 来实现左侧面板菜单

iphone - NSString 字符串与字符串 VS @"string"

iphone - 如果我弱链接应用程序中的所有框架会怎样?

objective-c - 接收者类型 ‘X’ 例如消息是前向声明 CGPOINT, IOS