How to handle next and previous button in the MPMoviePlayerViewController? - ios

I am getting all events of the player by this notification MPMoviePlayerPlaybackStateDidChange, but not getting the next/previous event/action.
Can we handle all actions with the Now playing info in the background of application with this player?
Please let me know.
Thanks

MPMoviePlayerController, post only MPMoviePlayerPlaybackStateDidChangeNotification even when stop, previous and next buttons are clicked. You cannot find directly which button is clicked.
For this you can create your own custom control with custom button actions, from this you can detect easily which button is clicked.
NOTE: Before creating the custom control you must set the player's controlStyle property to MPMovieControlStyleNone to hide the default controls.

Related

Hiding AVPlayerController full screen button

I am loading my AVPlayerController on a specified UIView. Is there a way to hide only the fullscreen button shown on the AVPlayerController?
What you can do is hide all the controls using:
YourAVPlayerViewControllerName.showsPlaybackControls = false
and then create your own custom controls for the player
EDIT:
Also as mentioned in the comments, you cannot remove only one button, if you need the excat the same then you need to customise your view based on your requirment
I'm afraid you cant, but you can create a customized player using AVPlayerLayer then you can do almost anything you want in it but you need to handle everything manually, slider and playback Controls and so.
there are already lots of tutorials on how to achieve that like this one

UIImagePickerController - Retake button on custom Overlay (Swift)

I am trying to implement a custom cameraOverlayView with a UIImagePickerController. I manage to hide the button and have my own interface , but a custom interface blocks the editing screen with the Preview option and the Retake. I noticed on some older posts adding two Notifications for "_UIImagePickerControllerUserDidCaptureItem", "_UIImagePickerControllerUserDidRejectItem" and then adding and removing the overlay would fix the issue. But with Swift 3 I cannot seem to find how to access these notifications and the delegate from UIImagePickerController is very limited. Is there another way ?
It seems like you cannot access the "Retake" event , so there is a need to create also a custom "Edit" screen. I have on the same customCameraOverlay , buttons for "Retake" and "Use it". So when the user stops capturing I hide the record and the cancel button and I present the retake and use it options, adding also a preview. So when the user clicks on retake I reverse the buttons again and remove the preview View. Likewise on "Use it" didfinishcapturing is being called

How can I post a manufactured event to UIButton

I'm writing a simple iOS 6.1 game. The game involves pressing buttons (OK, it's a tictactoe board, with the cells being UIButtons). The allows the player to choose whether to go first, or whether the computer should go first. If the player tells the computer to go first, I want to set some values, and then fire off the UIButton just as if the user had pressed it.
How can I post an event, or otherwise simulate the action of the button being pressed, to let the rest of the framework do the work of handling the button press?
If there is a better design approach, where I don't have to pretend that the computer has pressed a button, I'm open to hearing about that, instead.
Thank you
Your button will be connected to an action method, typically in your view controller. Just call that method yourself, passing the button as the sender.
Your method will be something like:
-(IBAction)buttonPressed:(UIButton*)sender
{
// Respond to your button press...
}
You'd call it as follows:
[self buttonPressed:self.whicheverButtonYouLike];
You'd need the buttons defined as outlets for this to work.

UIButton's click action?

I am following a book to learn IOs programming. For UIButton, it supposed to have a click action. However I only saw some actions like touch down etc.
Also, want to know why the default action not the "touch down" but "touchUpInside"
I am using XCode 4.3.
click action in iOS is represented but touchUpInside, since click is a mouse event
touchUpInside, means that the user touched down on a button, and then touch up, while he still is on the same button, which is the normal behavior when you want to tap on a button
In storyboard, you can right click on the UIButton and see the list of events available for a UIButton and choose appropriate event based on your requirement.
For a click like action you can use Touch Up Inside event.

Creating a custom toggle with UIButton in Interface Builder

Is this possible? It seems shoddy for it not to be.
I'm trying to create a toggle button (not a UISwitch) in IB. For example a mute button, when muted would have some indication that sound is disabled, when you hit it, that indicator disappears (but still the same underlying graphic), and toggles between these states each time it is pressed.
This functionality can be achieved using the selected property, however you can't change the Selected AND Highlighted property in IB like you can in code, so whenever the button is pressed, no matter the state, the highlighted image is the same, which looks terrible and glitchy.
Is there a way to fix this with just IB, or do I have to make a custom class to avoid manually loading in all these buttons?
Have you thought about subclassing UIButton to add in the things you need?

Resources