我的代码在这里:

在 View DidLoad中:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "doneButtonClick", name: MPMoviePlayerWillExitFullscreenNotification, object: nil)

我的处理程序:
func doneButtonClick(sender:NSNotification?){
    println("finishPreload");
}

let player:MPMoviePlayerController = MPMoviePlayerController()

我的 MPMoviePlayerController:
let videoUrl = (json[0]["files"][0]["furl"]).string

self.player.view.frame  = self.view.bounds
self.view.addSubview(self.player.view)

self.player.scalingMode = .AspectFill
self.player.controlStyle = .Fullscreen;
self.player.repeatMode = .One
self.player.contentURL = NSURL(string: videoUrl)
self.player.prepareToPlay()
self.player.play()

当我单击左上角的完成按钮时,视频停止,但未触发 doneButtonClick 方法,任何人都可以提供帮助吗?我已经尝试了 MPMoviePlayerWillExitFullscreenNotification MPMoviePlayerDidExitFullscreenNotification ,不工作时间。

最佳答案

您的 "doneButtonClick" 函数只有一个参数。所以你应该在函数名后使用 ":"

IE; NSNotificationCenter.defaultCenter().addObserver(self, selector: "doneButtonClick:", name: MPMoviePlayerWillExitFullscreenNotification, object: nil)

关于ios - 如何在 ios 8 swift MPMoviePlayerDidExitFullscreenNotification 中触发完成按钮事件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25459666/

10-09 22:52