UINavigationController: pop view controller in the opposite direction - iphone

I'm trying to call [[self navigationController] popViewControllerAnimated:YES] but making the animation slide right to left instead of left to right. Any easy way to do this? I want to return to the previous view. Any help is appreciated. Thanks!

This is how one can pop view controller in opposite direction. Its working for me 100%
CATransition *transition = [CATransition animation];
transition.duration = 0.45;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault];
transition.type = kCATransitionFromRight;
[transition setType:kCATransitionPush];
transition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController popViewControllerAnimated:NO];

It is possible, look at the following code I used a while back and try to make it work for yourself. Yu only need to change the setAnimationTransition
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
There are a few different kind of default animations to use, apples site says this kind of animations are possible:
typedef enum {
UIViewAnimationTransitionNone,
UIViewAnimationTransitionFlipFromLeft,
UIViewAnimationTransitionFlipFromRight,
UIViewAnimationTransitionCurlUp,
UIViewAnimationTransitionCurlDown,
} UIViewAnimationTransition;
So in your case you would want to use the following:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController popViewControllerAnimated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

Related

navigate to new page in iPhone

I am new to iPhone developer,
On click of button, i want to navigate to a new page with this animation, UIViewAnimationTransitionFlipFromLeft
How should i do this ?
-(void)btnClick{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
[UIView commitAnimations];
}
When i click on btn Animation happens but i am unable to navigate to new page.
Any Help Will be Appriciated !
ViewController *viewController = [[ViewController alloc]initWithNibName:#"View" bundle:nil];
[UIView beginAnimations:#"Flip" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationCurve:UIViewAnimationOptionCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:viewController animated:YES];
[UIView commitAnimations];
[viewController release];
viewController is the page u want to navigate to.
Pop:
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
You aren't specifying which views you want to swap in and out. At the moment you are just setting where the animation happens and what type of animation it is.
You need something like this.
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:NO];
[view1 removeFromSuperview];
[self.view addSubview view2];
[UIView commitAnimations];
I recommend reading this documentation as I dont think you understand the ViewController and View relationship entirely. There are different ways of transitioning between ViewControllers and individual views.
Just in the case of using this method your view1 would be LicAppViewController.view and assuming you PlanPage is a view then view2 is just PlanPage.

curl effect on landscape mode

i am trying to implement curl effect by using below code snippet
curl down
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.95];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view cache:YES];
[UIView setAnimationDidStopSelector:#selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
curl up
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.95];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDidStopSelector:#selector(animationDidStop:finished:context:)];
[UIView setAnimationDelegate:self];
but this works fine with portrait mode.
I want to implement it on landscape mode, taping on top right and bottom left.
currently its working in reverse effect.
Many Thanks
#import <QuartzCore/QuartzCore.h>
-(void)pageCurltoNextorPrevious:(UIView*)view:(int)identifier {
// Curl the image up or down
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:1.0];
CAMediaTimingFunction *fun=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
[animation setTimingFunction:fun];
if (identifier==1){
//next animation
animation.type = #"pageCurl";
animation.subtype=#"fromRight";
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 1.0; //0.58;
}
else {
//previous animation
animation.type = #"pageCurl";
animation.subtype=#"fromLeft";
animation.fillMode = kCAFillModeBackwards;
animation.startProgress = 0.0;
}
[animation setRemovedOnCompletion:NO];
//[view exchangeSubviewAtIndex:0 withSubviewAtIndex:2];
[[view layer] addAnimation:animation forKey:#"pageCurlAnimation"];
}
please,try this way.i used in view navigation by one View
1st view to go next Infoview i creat the curlup effect:
InfoView *objdb=[[InfoView alloc] initWithNibName:#"InfoView" bundle:nil];
[UIView beginAnimations:nil context:NULL ];
[UIView setAnimationCurve:UIViewAnimationTransitionCurlUp];
[UIView setAnimationDuration:1.0];
[self presentModalViewController:objdb animated:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[objdb release];
then back from infoview to main view then use this(curl down effect):
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationTransitionCurlDown];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self dismissModalViewControllerAnimated:YES];
[UIView commitAnimations];
i hope it's help for u.

Looking for a within app transition (revolving screen effect)

I want a transition within my app that is like the mystery revolving wall from old scooby doo cartoons. I want the screen to revolve when switching views. Anyone point me in the right direction for the possibility of accomplishing this?
Or this, which uses far less ink:
UIView *bookCaseView; // this is the container... the haunted wall
UIView *booksView; // just an ordinary set of books, right?
UIView *spookyBackside; // ruh-roh, raggy!
[UIView transitionWithView:containerView
duration:0.2
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
[booksView removeFromSuperview];
[bookCaseView addSubview:spookyBackside]; }
completion:NULL];
I think this is what you are looking for:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
//optional if you want to do something after the animation
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(myAnimationDidFinish:finished:context:)];
//
[view2 setFrame:CGRectMake(0, 0, view2.frame.size.width, view2.frame.size.height)];
[view1 addSubview:view2];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:view1 cache:YES];
[UIView commitAnimations];
And to flip back:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
//optional if you want to do something after the animation
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(myOtherAnimationDidFinish:finished:context:)];
//
[view2 removeFromSuperview];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:view1 cache:YES];
[UIView commitAnimations];

Subview fade in and fade out help

I am having a problem fading out my subview. I have no trouble fading the view in but fading out ..just drops the view.
-(void)flipToReview {
ReviewViewController *reviewVariable = [[ReviewViewController alloc] initWithNibName:#"ReviewViewController" bundle:nil];
[self setReviewViewController:reviewVariable];
self.ReviewViewController.view.alpha =0;
[UIView beginAnimations:#"flipview" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:YES];
[reviewVariable release];
[self.window addSubview:self.ReviewViewController.view];
self.ReviewViewController.view.alpha =1;
[UIView commitAnimations];
}
-(void)flipBackFromReview {
// self.ReviewViewController.view.alpha = 1;
[UIView beginAnimations:#"trip" context:nil];
[UIView setAnimationDuration:0.3];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:_window cache:NO];
self.ReviewViewController.view.alpha = 0;
[self.ReviewViewController.view removeFromSuperview];
[UIView commitAnimations];
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];
[self.ReviewViewController.view setHidden:1];
NSLog(#"remove subview");
}
Try the following:
[UIView animateWithDuration:3.0 delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{ ReviewViewController.view.alpha = 0.0;}
completion:^(BOOL fin) {
if (fin) [ReviewViewController.view removeFromSuperview];
}];
You need to move:
[self.ReviewViewController.view removeFromSuperview];
That cannot be done "over time" in an animation. What you want to do is move that to a selector and use setAnimationDelegate and setAnimationDidStopSelector. Put the following in your animation block:
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:#selector(finshedFadeOut)];
Then make the following method:
- (void)finshedFadeOut {
[self.ReviewViewController.view removeFromSuperview];
}
I had this issue as well, the way I got around it was changing the alpha to 0, instead of just removing the view. That can be animated.

popViewController doesnt seem to work with UIView animations

I have the following code, which does a nice animation when pushing a new view controller.
[UIView beginAnimations:#"animation" context:nil];
[UIView setAnimationDuration:0.5];
[[self navigationController] pushViewController:details animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
This code, using popViewController (rather than pushViewController) doesnt do the animation.
[UIView beginAnimations:#"animationback" context:nil];
[UIView setAnimationDuration:0.5];
[[self navigationController] popViewControllerAnimated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
Any ideas why this would be and more importantly; how can I fix it?
Are you sure that self.navigationController.view really refers to the right view ... the one being animated? I have the feeling that the first case works only by accident. Shouldn't you refer to the view of the controller being pushed / popped?