I want to add a short video when my app launches instead of launch image in iOS.
我希望在我的应用启动时添加一个简短视频,而不是在iOS中启动图像。
I have tried adding it in the viewDidAppear:
method of my initial UIViewController
, but still it shows a blank screen before it displays the video.
我尝试在我的初始UIViewController的viewDidAppear:方法中添加它,但在显示视频之前它仍然显示一个空白屏幕。
3 个解决方案
#1
4
You can not add a launch video instead of a launch image, but, your initial view controller can present a launch video which starts from the same image as your default (launch) image...
您无法添加启动视频而不是启动图像,但是,您的初始视图控制器可以显示启动视频,该视频从与默认(启动)图像相同的图像开始...
In any case, you should include the default (launch) image as it is displayed while the app is loading (and thus before the video is ready to be played).
在任何情况下,您都应该包含应用程序加载时显示的默认(启动)图像(因此在视频准备好播放之前)。
#2
1
A launch image is used by iOS to show BEFORE the app is ready to respond and while viewDidLoad:
and viewWillAppear:
are called. So there is no question of INSTEAD.
iOS将使用启动图像显示应用程序准备好响应之前以及调用viewDidLoad:和viewWillAppear:。所以INSTEAD没有问题。
I believe a launch image is a must for app submission for the App Store.
我相信启动图像是App Store提交应用程序的必备条件。
A launch image is a simple placeholder image that iOS displays when your app starts up. The launch image gives users the impression that your app is fast and responsive because it appears instantly and is quickly replaced by the first screen of your app.
启动图像是iOS在应用启动时显示的简单占位符图像。启动图像让用户感觉您的应用程序快速响应,因为它立即显示,并且很快就会被应用的第一个屏幕取代。
Also this is something you should read:
这也是你应该阅读的内容:
You must provide at least one launch image. Typically, an iPhone app includes at least one launch image in portrait orientation; an iPad app includes at least one launch image in portrait orientation and at least one launch image in landscape orientation.
您必须至少提供一个启动图像。通常,iPhone应用程序包括至少一个纵向的启动图像; iPad应用程序包括至少一个纵向启动图像和至少一个横向启动图像。
In general, consider reading these two pages:
一般来说,请考虑阅读这两页:
Start reading from the App Launch Images section: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html
从App Launch Images部分开始阅读:https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html
#3
1
The response is a little late but with Swift 2 you can install via CocoaPods VideoSplashKit library. Then just add a little of code in your viedDidLoad
响应有点晚,但使用Swift 2,您可以通过CocoaPods VideoSplashKit库安装。然后在viedDidLoad中添加一些代码
import VideoSplashKit
class ViewController: VideoSplashViewController {
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource("test", ofType: "mp4")!)
self.videoFrame = view.frame
self.fillMode = .ResizeAspectFill
self.contentURL = url
}
}
Edit: You can create a method to configure when the video starts and video duration
编辑:您可以创建一种方法来配置视频启动时间和视频持续时间
func setupVideoBackground() {
let url = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource("iphone6", ofType: "mp4")!)
self.videoFrame = view.frame
self.fillMode = .ResizeAspectFill
self.alwaysRepeat = true
self.sound = true
self.startTime = 0.0
self.duration = 100.0
self.alpha = 0.7
self.backgroundColor = UIColor.whiteColor()
self.contentURL = url
self.restartForeground = true
}
Here you can find and example with this library
在这里,您可以找到这个库的示例
#1
4
You can not add a launch video instead of a launch image, but, your initial view controller can present a launch video which starts from the same image as your default (launch) image...
您无法添加启动视频而不是启动图像,但是,您的初始视图控制器可以显示启动视频,该视频从与默认(启动)图像相同的图像开始...
In any case, you should include the default (launch) image as it is displayed while the app is loading (and thus before the video is ready to be played).
在任何情况下,您都应该包含应用程序加载时显示的默认(启动)图像(因此在视频准备好播放之前)。
#2
1
A launch image is used by iOS to show BEFORE the app is ready to respond and while viewDidLoad:
and viewWillAppear:
are called. So there is no question of INSTEAD.
iOS将使用启动图像显示应用程序准备好响应之前以及调用viewDidLoad:和viewWillAppear:。所以INSTEAD没有问题。
I believe a launch image is a must for app submission for the App Store.
我相信启动图像是App Store提交应用程序的必备条件。
A launch image is a simple placeholder image that iOS displays when your app starts up. The launch image gives users the impression that your app is fast and responsive because it appears instantly and is quickly replaced by the first screen of your app.
启动图像是iOS在应用启动时显示的简单占位符图像。启动图像让用户感觉您的应用程序快速响应,因为它立即显示,并且很快就会被应用的第一个屏幕取代。
Also this is something you should read:
这也是你应该阅读的内容:
You must provide at least one launch image. Typically, an iPhone app includes at least one launch image in portrait orientation; an iPad app includes at least one launch image in portrait orientation and at least one launch image in landscape orientation.
您必须至少提供一个启动图像。通常,iPhone应用程序包括至少一个纵向的启动图像; iPad应用程序包括至少一个纵向启动图像和至少一个横向启动图像。
In general, consider reading these two pages:
一般来说,请考虑阅读这两页:
Start reading from the App Launch Images section: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html
从App Launch Images部分开始阅读:https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/App-RelatedResources/App-RelatedResources.html
#3
1
The response is a little late but with Swift 2 you can install via CocoaPods VideoSplashKit library. Then just add a little of code in your viedDidLoad
响应有点晚,但使用Swift 2,您可以通过CocoaPods VideoSplashKit库安装。然后在viedDidLoad中添加一些代码
import VideoSplashKit
class ViewController: VideoSplashViewController {
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource("test", ofType: "mp4")!)
self.videoFrame = view.frame
self.fillMode = .ResizeAspectFill
self.contentURL = url
}
}
Edit: You can create a method to configure when the video starts and video duration
编辑:您可以创建一种方法来配置视频启动时间和视频持续时间
func setupVideoBackground() {
let url = NSURL.fileURLWithPath(NSBundle.mainBundle().pathForResource("iphone6", ofType: "mp4")!)
self.videoFrame = view.frame
self.fillMode = .ResizeAspectFill
self.alwaysRepeat = true
self.sound = true
self.startTime = 0.0
self.duration = 100.0
self.alpha = 0.7
self.backgroundColor = UIColor.whiteColor()
self.contentURL = url
self.restartForeground = true
}
Here you can find and example with this library
在这里,您可以找到这个库的示例