UIViewAnimationTransitionCurl in left and right direction - objective-c

Is there any way possible to use UIViewAnimationTransitionCurl in left and right directions? I'm looking for something similar to the Contacts app:

If you are targetting iOS 5, use UIPageViewController. The last fifteen minutes of the Implementing UIViewController Containment video from WWDC 2011 describe how to use it.

If you don't mind iOS 5 as a requirement you could use the new UIPageViewController
Otherwise you could try something like this:
self.appDelegate = [[UIApplication sharedApplication] delegate];
UIViewController *srcViewController = (UIViewController *) self.sourceViewController;
UIViewController *destViewController = (UIViewController *) self.destinationViewController;
[UIView commitAnimations];
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.25];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromRight forView:self.appDelegate.window.rootViewController.view.superview cache:YES];
[srcViewController.view removeFromSuperview];
[UIView commitAnimations];
[self.appDelegate.window addSubview:destViewController.view];
self.appDelegate.window.rootViewController=destViewController;
Cheers....

Related

iOS transition animation for pushViewController

I have an AppDelegate, which owns a window, and from there on, A main view, from which when I go to the next view, I push the new view in order to use the same Navigation Controller and toolbar:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
self.appview = [[AppointmentView alloc] initWithNibName:#"AppointmentView" bundle:[NSBundle mainBundle]];
#synchronized(self.MahAppntmnts){ // Set the view's appointment
[appview setMyAppointment:[[MahAppntmnts MyAppointments] objectAtIndex:indexPath.section]];
}
[super addChildViewController:self.appview];
AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[del.navigationController pushViewController:self.appview animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
}
Now this works fine for switching views, but when I'm trying to go back, I get the same boring flip transition.
I tried setting on my AppView's viewWillDissapear delegate method:
-(void) viewWillDisappear:(BOOL)animated
{
[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];
[super viewWillDisappear:animated];
}
This seems to work for when I go back to the previous view, but when I try to transition to new views (using the same method as before) they either not appear, or I flip by to the same view. So I'm guessing that this code should not be on viewWillDissapear, or that I am doing something wrong...
Well I found the solution, problem was my miss-conception to "whom" the animation belonged to. I added the code found in viewWillDissapear (located in the pushed view), to the viewWillAppear delegate of the view that did the pushing in the first place (the code found in accessoryButtonTappedForRowWithIndexPath), so that the controlling view initiates the animation when pushing another view, and when another view navigates back to it, the reverse animation is displayed. Solved all problems and works like a charm.

custom UIView animation in dismissModalViewController

Where is the correct place to put custom animation code for dismissing a modalviewcontroller.
I tried putting the following into viewdiddisappear, viewwilldisappear but doesn't behave correctly. Any thoughts? THanks!!
[UIView beginAnimations:#"suck" context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:103 forView:self.navigationController.view cache:YES];
[UIView setAnimationPosition:CGPointMake(260, 431)];
[UIView commitAnimations];
Try this:
UIViewController *myController = [[[MyViewController alloc] init] autorelease];
UIViewAnimationTransition transition = UIViewAnimationTransitionCurlUp; // or whatever effect you want
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:transition forView:[self window] cache:YES];
[navController presentModalViewController:myController animated:NO]; // or dismissModalViewController in your case
[UIView commitAnimations];
I think I figured it out. I followed the example in:
http://developer.apple.com/library/ios/#samplecode/BubbleLevel/Introduction/Intro.html
Basically removed the second view from superview and inserted the first view back in. The transition works correctly afterwords.
THanks for the help.

Custom Segue with UIViewAnimationOptionTransitionCurlDown

I'd like create a custom segue to swap ViewControllers with a curl up animation but I can't find a way, What would be the -(void)perform for this?
I've got this
-(void)perform{
UIViewController *dst = [self destinationViewController];
UIViewController *src = [self sourceViewController];
[UIView beginAnimations:nil context:nil];
//change to set the time
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:src.view cache:YES];
[UIView commitAnimations];
}
But I don't get to change the view, anyway thanks for your help!
Nevermind, I solved it, for the record the only thing I had to do was add a Navigation Controller and then I could use custom segues like:
- (void) perform {
UIViewController *src = (UIViewController *) self.sourceViewController;
UIViewController *dst = (UIViewController *) self.destinationViewController;
[UIView transitionWithView:src.navigationController.view duration:0.3
options:UIViewAnimationOptionTransitionFlipFromBottom
animations:^{
[src.navigationController pushViewController:dst animated:NO];
}
completion:NULL];
}

Switching view by changing delegate rootViewContoller

I'm presently trying to switch view from a UIViewController to a SplitViewController. I'm currently doing this in my UIViewController:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[UIView transitionWithView:delegate.window duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
delegate.window.rootViewController = delegate.splitViewController;
} completion:nil];
[self.view removeFromSuperview];
Is it the right way to switch view ? If yes, I still have a problem to solve with that method.
It first quickly shows the MasterView in Portrait Mode and then show the whole split view in the current orientation mode of the iPad.
I hope I'm clear enough.
Thank for you help.
I found a way to make it work from that thread :
RootViewController animation transition, initial orientation is wrong
AppDelegate *delegate =(AppDelegate *)[[UIApplication sharedApplication] delegate];
[UIView transitionWithView:self.window duration:0.5 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
BOOL oldState = [UIView areAnimationsEnabled];
[UIView setAnimationsEnabled:NO];
delegate.window.rootViewController = self.splitViewController;
[UIView setAnimationsEnabled:oldState];
}
completion:nil];

bottom up animation using Pushviewcontroller?

I am new to Iphone SDK.i am using following code.but the animation happens
from Right to Left when i click this button.i want to do fro botton to Up
- (IBAction)clickedsButton:(id)sender
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:settingsController animated:TRUE];
[UIView commitAnimations];
}
setAnimationTransition supports only Two ...
1)UIViewAnimationTransitionFlipFromLeft
2) UIViewAnimationTransitionFlipFromRight..
any help please? i used following, but it is not working
settingsController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self.navigationController pushViewController:settingsController animated:YES];
What you're looking for is
- (void)presentModalViewController:(UIViewController *)modalViewController animated:(BOOL)animated;
SWIFT 3
self.present(newViewController, animated: true, completion: nil)