IOS: curl from right - ios

I have this code:
- (IBAction)open:(id)sender{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[splash removeFromSuperview];
[UIView commitAnimations];
}
I have an imageView "splash" and I remove it with the IBAction, but my problem is that it remove splash from left, and I want to remove it from right, what can I do?

There is no UIViewAnimationTransitionCurlRight nor Left in the iOS.
For IOS5 projects you can use the new UIPageViewController that is working similar to the iBooks App.
you can see my answer here with links - Page curl - Leaves Project - Interaction elements
For other versions you can find here a work around to set this curl:
I want to use animation to imageview using UIanimationtransitioncurl right or left. Is it possible?
Good Luck

Related

Frame for "Banner View" will be different at run time. iAd works for largest screen but blank on smaller ones

I've nearly finished my app and the only issue I have is that my iAd banner view will only show on the largest screen.
I have set the constraints so the iAd will fit nicely on smaller screens but when I run it on any size other than the largest, all I see is a white box.
The current code I have is:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
I'm wondering if I should add a line of code to the bannerViewDidLoadAd to say something about the frame size.
The error I keep getting is:
Frame for "banner view" will be different at run time.
Size will be (320,50) at runtime but is (480,60) in the canvas.
The iAd framework has been imported and the add delegated.
It's within a scroll view if that makes any difference.
All my constraints are fine it's just this frame size that's the issue. if i attempt to update frames nothing happens.
Any help would be greatly appreciated.
Thanks.
Sounds like you have trailing and leading constraints set on your ADBannerView.
Your ADBannerView will know which device it is on and set the dimensions of the ADBannerView accordingly. You should just let Auto Layout know where you want your ad to be. For example, if you wanted your ADBannerView to be at the bottom of your view then you would pin it to the bottom of your view with Bottom Space to: Bottom Layout Guide and align it to Align Center X to: Superview.
Also, don't use the beginAnimations:context: method. From UIView Class Reference:
Use of this method is discouraged in iOS 4.0 and later. You should use
the block-based animation methods to specify your animations instead.
Using block-based animations, your delegate methods would end up looking like this:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView animateWithDuration:1.0 animations:^{
banner.alpha = 1.0;
}];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView animateWithDuration:1.0 animations:^{
banner.alpha = 0.0;
}];
}

Detect edges of the screen UIView animation

I have an UIView animation to move an object on the screen and I want the animation to be stopped (and the object to keep the position when the animation is stopped) when the object goes off the screen.
I want my object to always be visible, and to stop moving when it meets an edge of the screen. The target point may be anywhere.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
self.MyObject.center = targetPoint;
[UIView commitAnimations];
I tried to fire a scheduled timer which check if the object is off screen but it seems that the position my object does not change.
Thanks for your help.
Below is the code sample if you are looking to animate the object from left to right edge of the screen.
CGRect objectFrame = self.MyObject.frame;
objectFrame.origin.x = self.view.frame.size.width-objectFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[self.MyObject setFrame:objectFrame];
[UIView commitAnimations];
Hope it helps.
Cheers.

How to create custom UIViewAnimation

What is the simplest way to create a custom UIView animation transition? Most of the tutorials that pop up in a Google search are not recent. (I'm using XCode 4.5 version) In my current iPhone app I have the following code for my screen transitions:
[UIView beginAnimations:#"View flip" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.25];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView commitAnimations];
I want something unique instead of the 5 or 6 built-in transitions. Any ideas or suggestions on where to start?
I think this is what you are looking for:
[UIView animateWithDuration:0.3 animations:^{
//Move frame or transform view
}];
Inside that block you can put arbitrary animation code.

How to do the page curl like in storybook app in iPad

I am working on a storybook app, i want to do the page curl like in the following video.
Demo Video
Can anyone tell me how to do exactly like this.
Update:
I want this page curling to support iOS 4.3+. UIPageViewController will work only on iOS 6.
You might want to consider UIPageViewController. It is quite useful in creating apps which use page curling animations. Here is the documentations link.
You can make use of the UIView's animation effect for this. I guess this should help you
[UIView beginAnimations:#"Curl" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:contentView cache:YES];
[UIView commitAnimations];
where the contentView is the view where you are applying the animation. By varying the duration and animation curve you can modify your animation effect.
There are two ways of doing it:
The hard way, implement everything yourself (from scratch, with layers and masks and transforms and gradients) and a lot of headache.
the Easy way, read the documentation for UIPageViewController as suggested by #Zen. Its very useful and gives you the exact animation that you want (as shown in video). Or, using some third party code.
If you dont't have time constraint, then I will say, go the first way. You will learn a lot.
Cheers, have fun :)
EDIT
Here is the link to a sample app:
https://www.dropbox.com/s/x4qo2igrzvnkj16/CurlAnimationProject.zip
check it and tell me what you think.
SettingViewController *svc = [[SettingViewController alloc]initWithNibName:#"SettingViewController" bundle:nil];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:2];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[self.navigationController pushViewController:svc animated:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
As mentioned several time in the answers the UIPageViewController (apple documentation) is the thing you should be looking at.
The implementation is fairly straightforward, the controller uses 2 delegates
datasource : controlling the content to display (your pages) through 2 main methods
delegate : controlling its behaviour
It implements the swipe gesture for scrolling from page to page and can feature a page control at the bottom of your view.
For transitioning from page to page, you can either set a scroll animation (nice for photo / portfolios type) or the page curl you are looking for.
You can make page curl/flip effect by
For landscape mode:
[UIView beginAnimations:#"Curl" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:contentView cache:YES];
[UIView commitAnimations];
For portrait mode:
[UIView beginAnimations:#"Curl" context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlLeft forView:contentView cache:YES];
[UIView commitAnimations];

iOS: UIView animation, no animating happening

Having a puzzling problem. I have a universal app with a lot of shared code between the iPad and iPhone versions. There are different layouts in the nibs but essentially the same views and view hierarchy - one UIView used as a container for two sibling UITextViews.
UIView mainView with children:
UITextView passageTextView
UITextView notesTextView
One UITextView is hidden, the other visible.
The following is my code. The section commented out was my original animation attempt. This worked just as desired on the iPad, but not on the iPhone. The uncommented section is take 2, using the method recommended in the docs. The uncommented code does not work on either the iPad or iPhone - it hides/unhides my views but without any animation. If I add code to the completion block that also gets executed, so it's doing something, just not animating.
/*
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
passageTextView.hidden = YES;
notesTextView.hidden = NO;
[UIView commitAnimations];
*/
UIViewAnimationOptions options = UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationTransitionFlipFromRight;
[UIView transitionWithView:mainView
duration:1.0
options:options
animations:^{ passageTextView.hidden = YES; notesTextView.hidden = NO; }
completion:NULL];
Edit: Still working on the problem, hoping someone has a suggestion.
Additional update
Figured out why the following was not working in the iPhone:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
passageTextView.hidden = YES;
notesTextView.hidden = NO;
[UIView commitAnimations];
I had neglected to wire the view to mainView in Interface Builder. Hours debugging and I just now thought to check that.
But, I still do not know why animation blocks are not working for either the iPhone or iPad. I have tried several approaches but I'm not getting any animation even though the show/hides are working.
I think you are using the wrong animation option.
Replace your second animation option by UIViewAnimationOptionTransitionFlipFromLeft (note the Option between Animation and Transition)
I believe that UIViewAnimationTransitionFlipFromLeft (which is what you have in your code) is a UIViewAnimationTransition not a UIViewAnimationOptions.

Resources