how to push a viewController with flip animation - pushviewcontroller

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
alarmViewController = [[AlarmViewController alloc] init];
[self.navigationController pushViewController:alarmViewController animated:YES];
[alarmViewController release];
[UIView commitAnimations];
I just want the viewcontroller flip like opening a book page,but it does not work like this.And I have a question that whether navigationController can animate this effect?

Since you are already putting the navigationController in an animation block. Mark animated:NO -
[self.navigationController pushViewController:alarmViewController animated:NO];
when we actually call pushViewController: we are setting the animated value to NO. This disables the Navigation Controller's default animation. Instead, the block of code uses the defined transition.

Related

Push view controller flip transition doesn't include navigation bar

I am pushing a view controller whilst animating it so it flips. However, the animation is only applied to the view beneath the navigation bar, so the navigation bar hides for a few seconds then suddenly appears again. How can I apply the animation to the entire view, including the navigation bar?
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"OverviewiPad" bundle:nil];
OverviewViewController *overviewVC = [sb instantiateViewControllerWithIdentifier:#"OverviewViewController"];
overviewVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:overviewVC animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

Creating a custom View Controller Animation

I am trying to create a view controller animation where the view controller the user is currently on slide down and of the screen, revealing the new view controller bellow. So the new view controller would act like a background, with the new one sliding down and revealing it. I have given it a shot but haven't had any success. How would you recommend doing this?
Here is what I have tried:
-(void)showLogout:(UIButton *)sender {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:#"TermsAccepted"];
WelcomeViewController *welcomeViewController = [[WelcomeViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
self.view.frame = CGRectMake(0, 1200, 320, 568);
[self.navigationController pushViewController:welcomeViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView commitAnimations];
}
try this
-(void)showLogout:(UIButton *)sender {
[[NSUserDefaults standardUserDefaults] setBool:NO forKey:#"TermsAccepted"];
WelcomeViewController *welcomeViewController = [[WelcomeViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController cache:YES];
self.view.frame = CGRectMake(0, 1200, 320, 568);
[self.navigationController pushViewController:welcomeViewController animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView commitAnimations];

iPhone - Flip animation when navigation controller popped

How to Flip animation when navigation is controller popped, how we can achieve this
Following code for the flip animation for pop view
[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];
Following code for the Animation Block
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:transition forView:self.navigationController.view cache:NO];
}];
[self.navigationController popViewControllerAnimated:NO];
Try This Below Code to Push your View to next view.
-(IBAction)gotonextView:(id)sender
{
NextView *info = [[NextView alloc]initWithNibName:#"NextView" bundle:nil];
UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:info];
info.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self.navigationController presentModalViewController:nvc animated:YES];
}
Automatically You will get the same flip animation while popping out.

Stop UITableView Animation on push to UINavigationController

I'm pushing a view controller that contains a tableiview onto my uinavigation controller:
CourseMenuViewController *mvc = [[[CourseMenuViewController alloc] initWithSlidingNavigationcontroller:self.slidingNavigationController] autorelease];
mvc.course = course;
[self.navigationController pushViewController:mvc animated:YES];
[self.navigationController setNavigationBarHidden:NO animated:NO];
So far so good, everything works as expected. My issue occurs when I watch the animation and see all of my table view rows animate down from the top of the screen as the view is animating in from the left. This makes it feel like the view is moving from the top-left corner to the bottom-right corner in a diagonal path.
My question is, how can I make the table view just appear instead of animating? I should add that all of my cells are static so I'm not waiting on any data from a NSFetchedResultsController or anything like that.
roronoa below put me on the right path, and here is the now working version:
CourseMenuViewController *mvc = [[[CourseMenuViewController alloc] initWithSlidingNavigationcontroller:self.slidingNavigationController] autorelease];
mvc.course = course;
CATransition *caTransition = [CATransition animation];
caTransition.duration = 0.35;
caTransition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
caTransition.delegate = self;
caTransition.type = kCATransitionPush;
caTransition.subtype = kCATransitionFromRight;
[self.navigationController.view.layer addAnimation:caTransition forKey:nil];
[self.navigationController pushViewController:mvc animated:NO];
You have not mentioned details about your class CourseMenuViewController and initWithSlidingNavigationcontroller , but you can use the following to get the job done:-
CourseMenuViewController *mvc =[[CourseMenuViewController alloc] init];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[self.navigationController pushViewController:mvc animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[mvc release];
you can have any type of animation that you want in the above code by changing the animation constants according to your need without having unwanted animations on your tableview.

IOS: custom transition for a viewController

I have this code in my app to do a transition for a viewcontroller
SecondViewController *second = [[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
[self.view addSubview:second.view];
[second.view setFrame:CGRectMake(320, 0, 320, 480)];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.40]; //the double represents seconds
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[second.view setFrame:CGRectMake(0, 0, 320, 480)];
[UIView commitAnimations];
and it work fine;
but inside second view controller I have this code to disappear this viewcontroller
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.40]; //the double represents seconds
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[self.view setFrame:CGRectMake(320, 0, 320, 480)];
[UIView commitAnimations];
it work fine, but what's the way to release it, where can I release this second that I alloc when I call it??
if I write [self.view removeFromSuperView]?? is it released??
You need to remove it from the superView then release the SecondViewController that you allocated in your code.
SecondViewController *second = [[SecondViewController alloc]initWithNibName:#"SecondViewController" bundle:nil];
So since you are owning this object you need to release it.
So somewhere after hiding the second view, and removing it from superView, you need to release it...
[second release];

Resources