I am using a MPMoviePlayer to display a video. I go into full screen and when the done button is clicked I want it to remove of the entire movie player from my view. Currently it only goes out of the fullscreen mode. How do you track the doneButton being clicked or just how do I go about fixing this issue?
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Could I create “Call” button in HTML 5 IPhone appl
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Swift - hide pickerView after value selected
To the best of my knowledge, you can't be notified when the Done button is clicked. You can, however be notified when the movie player exits fullscreen after the Done button is clicked. For this, you use the MPMoviePlayerDidExitFullscreenNotification
To observe and act upon this notification you need to paste the following code in your class file which contains the IBAction (put it in the
viewDidLoad
method):Now you need to create the
exitedFullScreen
method in the same class:Finally, in your
viewDidUnload
method, paste the following line:To explain what's going on:
The "addObserver" line of code in your viewDidLoad makes sure your viewController responsible for handling the moviePlayer is listening to the MPMoviePlayerDidExitFullScreen notification.
That line makes it so that when the notification comes is, the exitedFullScreen method is fired off, where you would put the code you wanted to run when the Done button was clicked.
In the viewDidUnload, the viewController is going to be unloaded so you want to stop listening to the notification, hence the removeObserver part.
You can do that by adding a notification handler on
MPMoviePlayerDidExitFullscreenNotification
as that notification gets sent once the user taps on the DONE Button.Somewhere in your initializer
Now implement that handler: