- я создал контроллер представления заставки и загружаю его при запуске приложения. но белый экран отображается на несколько секунд, прежде чем мой экран-заставка VC покажет какое-либо исправление?
- В видео, которое я показываю, отображается только черный экран. Я не могу догадаться, что я сделал не так. Ниже приведен код для него.
Код: Выделить всё
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) let vc = SplashScreenVC(nibName: "SplashScreenVC", bundle: nil) let rootViewController = UINavigationController(rootViewController: vc) self.window?.rootViewController = rootViewController self.navigationController?.navigationBarHidden = true self.window?.makeKeyAndVisible() // Override point for customization after application launch. return true
Код: Выделить всё
class SplashScreenVC: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.navigationController?.navigationBarHidden = true playVideo() } func playVideo() { let moviePath = NSBundle.mainBundle().pathForResource("animationVideo", ofType: "mp4") let movieUrl = NSURL.fileURLWithPath(moviePath!) let moviePlayer : MPMoviePlayerController = MPMoviePlayerController(contentURL: movieUrl) moviePlayer.prepareToPlay() let vV = self.view.viewWithTag(SplashScreenUITags.videoView.rawValue)! as UIView moviePlayer.controlStyle = MPMovieControlStyle.None moviePlayer.scalingMode = MPMovieScalingMode.Fill moviePlayer.movieSourceType = MPMovieSourceType.File; moviePlayer.view.frame = vV.bounds vV.addSubview(moviePlayer.view) moviePlayer.play() NSNotificationCenter.defaultCenter().addObserver(self, selector: Selector("moviePlayBackDidFinish:"), name: MPMoviePlayerPlaybackDidFinishNotification, object: moviePlayer) } }
Подробнее здесь: https://stackoverflow.com/questions/354 ... ash-screen