应用程序在iPhone中以黑屏开始

时间:2015-10-12 16:01:50

标签: ios objective-c iphone swift

我改变了#34;启动屏幕文件"到我的" Main.Storyboard"在设置中。在做这个应用程序之前工作正常,并直接打开没有任何问题。但在添加之后,在故事板发布之前有一个黑屏。这是非常糟糕的用户体验。帮我解决这个问题。 AppDelegate和viewController没什么大不了的。我在项目中有一个LaunchScreen.xib,在图像资产中也有LaunchImage。我在项目中使用Storyboard。我不想在我的应用中使用launchScreen,我只是想直接进入我的故事板。

    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。谢谢大家:))

2 个答案:

答案 0 :(得分:1)

在appdelegate中使用此代码来实现目标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];

对于斯威夫特......

 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
}

答案 1 :(得分:0)

启动屏幕不同的Main.StoryBoard。在启动屏幕文件中,您必须键入:“LaunchScreen”并选择文件Lscreen.storyboard(xcode7),或.xib如果Xcode6