简体   繁体   English

在Swift中的代码中添加启动屏幕到iOS应用程序(没有故事板或Launchboard)

[英]Add a Launch Screen to the iOS App in Code in Swift (without Storyboard or Launchboard)

I created my views in code. 我在代码中创建了我的视图。 The starting point is the didFinishLaunchWithOptions function in the Appdelegate class. 起点是Appdelegate类中的didFinishLaunchWithOptions函数。

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.makeKeyAndVisible() 
    let controller = ViewController() // create an instance of my ViewController and set it to the rootViewController
    window?.rootViewController = controller

I would like to add a launch screen that appears instantly when your app starts up. 我想添加一个在您的应用启动时立即显示的启动屏幕。 The launch screen should be quickly replaced with the first screen of the app, giving the impression that your app is fast and responsive. 应该使用应用的第一个屏幕快速替换启动屏幕,从而给人以您的应用快速响应的印象。 I found some answers that said it is not possible( Is there any way to code the LaunchScreen programmatically ). 我发现一些答案说它不可能( 有没有办法以编程方式编写LaunchScreen代码 )。 My idea was creating a new launchView and replace it through NSTimer. 我的想法是创建一个新的launchView并通过NSTimer替换它。 Isn't there any easier or alternative way ? 有没有更简单或替代的方式?

Thanks 谢谢

This is not possible as such as the Launch Screen is not a regular View Controller and it cannot hold any logic. 这是不可能的,因为启动屏幕不是常规的视图控制器,它不能保持任何逻辑。 Any animations which are there in the App during startup are handled after the launch Screen has appeared and the animations are in the root view controller as in Twitter app. 启动期间应用程序中存在的任何动画都会在启动屏幕出现后处理,并且动画在Twitter应用程序中位于根视图控制器中。 If you are completely against using launch Screens then an alternative would be make a view in IB and use its screenShot as a splashImage. 如果你完全反对使用启动屏幕,那么另一种方法是在IB中创建一个视图并将其screenShot用作splashImage。 There is no way as of now to make a launchScreen programatically or to add any logic to it. 到目前为止,无法以编程方式创建launchScreen或向其添加任何逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在iOS Universal app中启动屏幕故事板约束 - Launch screen storyboard constraints in iOS Universal app iOS启动屏幕故事板与启动图像 - iOS Launch Screen Storyboard vs Launch Images iOS / Swift / Storyboard:仅使用屏幕的“一部分”添加PageViewController吗? - iOS/Swift/Storyboard: Add PageViewController using only *part* of screen? iOS Swift-导航到没有Storyboard的主屏幕 - IOS Swift- Navigate to Home screen without Storyboard 使用Swift和iOS 8 Storyboard登录屏幕 - Login Screen with Swift and iOS 8 Storyboard 启动带有居中图像 iOS 的屏幕情节提要 - Launch Screen Storyboard with centered image iOS iOS启动图像没有故事板或图像 - iOS Launch Image without Storyboard or Images 根据我的Xamarin Forms iOS应用中的文化更改启动屏幕故事板图像 - Change a launch screen storyboard image based on culture on my Xamarin Forms iOS app Cordova iOS App在Launch Storyboard和First Screen之间获得白色Flash - Cordova iOS App Getting White Flash between Launch Storyboard and First Screen 为 AppStore 的新 storyboard 要求更新具有 a.xib 启动屏幕的旧 iOS 应用程序的最简单方法是什么? - What's the easiest way to update an old iOS app with a .xib launch screen for the AppStore's new storyboard requirement?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM