how to disable user interaction for a button - iphone

i have a play button in my view,if i press play its gets updated the stream and started playing..
until i get play song i dont want to take any user interactions on play button..
can any ony help me on this.....

button.userInteractionEnabled = NO;

You could also set the "Enabled" property to "NO" or if you want animation, fade the alpha out.

Related

Always show AVPlayer controls

I have an AVPlayerViewController with a AVPlayer in it, and what I need is that the controls of the player (play, pause, time slider) never hides. Right now after more or less 4 seconds of playing the video the become hidden, and you have to tap the screen to show them again. I haven't been able to find a solution to that.. any ideas? thx!
You can set that by using Key-Value Coding
Swift:
// playerController : AVPlayerViewController
playerController.setValue(false, forKey: "canHidePlaybackControls")

disable the click event of button in iPhone

I am new to iPhone development.
In my application,
i want to disable the click event of button when it pressed first time by the user.
for that purpose
i tried
buttonname.Enable=FALSE;
But the image of button also goes washed like a disable.
i Want to show Image properly and button should be disabled, both at time.
what to do?
Please help me.
Thanks For Your Time.
Set buttonname.userInteractionEnabled = NO; This will disable the action of the buttonname but the UIButton will be shown. Only the clicked event will not work.
Use this code it may help you
[buttonName addTarget:self action:nil forControlEvents:UIControlEventTouchDown];
Try setting its userInteractionEnabled property to NO.

Drag UIButton on long press in iPhone

I am new in iPhone development.
I want to create one application in which whenever user long presses the button, it will be shaken and user is able to drag it on the screen and he will also be able to change its location.
I have tried this code.
- (void)handleLongPress:(UILongPressGestureRecognizer*)sender
{
NSLog(#"Long press called!!!!");
}
Check out the MoveMe sample app. It will show you how to allow movement of subviews by touch and drag.
http://developer.apple.com/library/ios/#samplecode/MoveMe/Introduction/Intro.html
you can also download that sample code ... :)

Loading MPMoviePlayerViewController with transparent background?

i´ve added a MPMoviePlayerViewController instance and playing of a movie works great.
I´ve 3 buttons and want to load different videos in a UIView-container. That works, too.
But if i click on a button to load an other video, everytime the background is flickering black.
I´ve set the color to "clearColor":
player.moviePlayer.backgroundView.backgroundColor = [UIColor clearColor];
But that doesn´t help. Is there a way to load a video without a background - only the video-content?
Thanks for your time.
Not sure about the flickering issue. You said it flickers when you load another video -- Are you unintentionally layering multiple videos on top of each other? Make sure you remove the old one!
The black background likely is because your
MPMoviePlayerController's
scalingMode property is set to MPMovieScalingModeAspectFit (Apple's Documentation:
MPMoviePlayerController
scalingMode)
For issue #2, like you, I had expected setting the backgroundView's color to handle this, however it seems there is another view behind that which you also need to set the backgroundColor to clearColor. My hack for this was to simply iterate through the movie player's subviews and set their backgroundColor to clear.
Hack/"Solution" example using your variable name:
for(UIView* subV in player.moviePlayer.view.subviews) {
subV.backgroundColor = [UIColor clearColor];
}
You have to re-apply clearColor to the subviews any time you enter/exit fullscreen mode as well. I hope someone else has a better solution because this method seems pretty kludgy.
another option is to hide the video player and then show it when it is ready to display
caveat needs IO6>= i believe:
https://stackoverflow.com/a/19459855/401896

Cocoa-Touch How to: MPMoviePlayerController loop?

I have an app with a splash screen. For the splashscreen I've decided to add a m4v movie. I'm using the MPMoviePlayerController to show the movie. Everything is working as expected except for one thing:
I'm trying to make the MPMoviePlayerController loop by subscribing to it's MPMoviePlayerPlaybackDidFinishNotification notification and issuing a [notification.object play] if the data didn't finish loading.
This works partially, it restarts the movie, but there's the fadeout and re-fadein that make it look bad.
Is there any other way to loop the movie?
Or any way to remove the fades?
Try this single line of code:
myPlayer.repeatMode = MPMovieRepeatModeOne;
:)
By complete coincidence I have just written a blog post on this subject - we ran into this problem while we were writing our latest app :)
Assuming that you don't want to follow my shameless plug, here's how we fixed it :
Make sure that the movie starts
and ends on the same frame.
Make the starting frame the Default.png of the app
On startup add Default.png to the window as a UIImageView
Make the movie have a clear background
Play and loop the movie
When the movie ends, it will fade out before it loops round. As Default.png is exactly the same as the start and end frames, the user will never notice :)
When you want to end the movie just remove the Default.png UIImageView and stop the movie - as the background is clear it will just fade out to whatever ui you have in your window.
Sam
I don't think there is any public option to do this. You could try and inspect Erica Sadun's Class Dumps for a method you can override that would handle the fading. Maybe a videoDidFinish method or something.
Have you tried messing around with the backgroundColor property? Apple's MPMoviePlayerController docs say
"The receiver fades to and from the
background color when transitioning to
and from playback...The default color
for this property is black. You can
change this to other colors (including
clear) to provide a more appropriate
transition from your application’s
content to the movie content."
So, you can probably try setting it to [UIColor clearColor] and seeing if that helps.