Stop user interaction on view - objective-c

My code does an animation that flips from right to left. The problem is while its switching, only a .75 second animation, the user is still able to interact with the program. I dont want them to be able to, is there a way to stop all user interaction for a short time, or just a way to stop it completely, then i can just use a timer to put it back on. here is my code for the animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:[self view]
cache:YES];
[UIView commitAnimations];
Thanks, Jacob

Try:
[self.view setUserInteractionEnabled:NO];

Related

Steady Animation?

I am making a iPhone/iPad app with a cursor and music. I am running a timer every beat and moving it like so:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:theLength];
[UIView setAnimationBeginsFromCurrentState:YES];
theCursor.frame = CGRectMake(theX, 0, 6, 320);
[UIView commitAnimations];
However, it seems to start off fast then slow down as it gets to the end. Is there any way to make the animation steady?
That's the animation curve. By default it is set to UIViewAnimationCurveEaseInOut. Use setAnimationCurve: to set it to UIViewAnimationCurveLinear.
You should also be aware that that way of animating is deprecated and Apple now recommend using the block-based animation style.

How to let two animations for UIView executed one by one

I have a small UIView and want to let it move to center of screen first, and then, zoom to full screen.
But when I begin start an animation like
[UIView beginAnimations:#"animation1" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(showDetailToFullscreen)];
self.currentDetailVC.frame = centerFrame;
[UIView commitAnimations];
And in the same controller, I have a method:showDetailToFullscreen
- (void)showDetailToFullscreen {
CGRect screenFrame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
[UIView beginAnimations:#"animation2" context:nil];
[UIView setAnimationDuration:0.5];
self.currentDetailVC.view.frame = screenFrame;
[UIView commitAnimations];
}
but when start, it still executed together.
I think the problem they are still in the same transaction. But how can I let these two animation executed one by one? Appreciate for any answer!
Try this instead of the setAnimationDidStopSelector:
[self performSelector:#selector(showDetailToFullscreen) withObject:nil afterDelay:0.5];
It's now considered much better to annimate views using the 'blocks' methods that can be found in the "Animating Views with Blocks" section in the UIView Class Reference.
In most of these methods you can specify a "completion" block of code that can be used to start off a second animation when the first animation completes. You could also call showDetailToFullscreen within this completion block.
I'd reccommend trying this method instead.
Are you targetting iOS 4 or later? If so, I recommend using the block-based animation methods instead. What you want to do is very easy:
Example from UIView docs:
[UIView animateWithDuration:0.2
animations:^{view.alpha = 0.0;}
completion:^(BOOL finished){ [view removeFromSuperview]; }];

Cocoa Touch - Slow Moving CGPointMake

I'm using the following code to move an UIImageView across screen. With this code it rockets across the screen but I want it to slowly move. What do I need to do?
[UIView beginAnimations:#"slide-up" context:NULL];
astroid_1.center = CGPointMake(astroidPosX,astroidPosY); // change this to somewhere else you want.
[UIView commitAnimations];
Thanks!
You need to set the duration of the animation:
[UIView setAnimationDuration:1.0];

swapping views with cool page turn animation

Below is code that I'm using to swap views
MySecondViewController *tempVC = [[MySecondViewController alloc] initWithNibName:#"MySecondView"];
[self presentModalViewController:tempVC animated:YES];
[tempVC passDataWithString:#"a string" andColor:yellowcolor];
How can I get the cool page turning animation (as with iBook or ROAD RAGE SIGN)
I don't want the user to actually tap and drag his finger on the screen. I want him to push a button and the animation occurs by itself.
Have you looked at UIViewAnimationTransition values? Use them in a UIView animation block. eg:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp
forView:self.view cache:YES];
[UIView commitAnimations];

UIButton Buy Now effect

I want to make a "Buy Now" button in my Application, which should work the same way as the one in the App Store, but I dont know how to resize the UIButton with an animation.
I have tried the following, but it resized the button at once and not as an animation:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:10.5];
[buyButton setFrame:CGRectMake(20, 115, 70, 21)];
[UIView commitAnimations];
Where the "buyButton" is a UIButton.
I've checked ou this post UIButton AppStore buy button animation, but is does not seem to work.
Try this:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:duration];
CGAffineTransform scale = CGAffineTransformMakeScale(scalingFactorX, scalingFactorY);
buyButton.transform = scale;
[UIView commitAnimations];
Using CGAffineTransform may help. I have not tried this, however, it should work.
the sample code on theapptree.com for the inapp purchase should do what you want.
http://www.theapptree.com/samples