Flip transition UINavigationController push does not call viewDidLoad until animation completed - ios

I'm animating UINavigationController push to be a flip following this, but the problem is that viewDidLoad does not get called until the animation is completed, which looks bad since I'm loading photos and such on the destination view controller. How can I ensure that the destination view controller is 'ready to go' (viewDidLoad) called and everything initialized before the animation starts?
[UIView transitionWithView:self.navigationController.view
duration:0.75
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[self.navigationController pushViewController:viewcontroller animated:NO];
}
completion:nil];

It sounds like your order of events is mixed up. Ideally the photos should get loaded in their own method. You can call this in the "ViewWillAppear" method so it's done before the view is loaded. In your case, if you move the image loading to a method, you can call it just above your [self.navigationController pushViewController:viewcontroller animated:NO]; line.
[viewcontroller loadImageMethod];
[UIView transitionWithView:self.navigationController.view
duration:0.75
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[self.navigationController pushViewController:viewcontroller animated:NO];
}
completion:nil];

Related

Seeing a flicker mid-transition?

I just tried my making a custom transition between view controllers. It basically spins the next one into view, and it works. Except that the source view controller flickers briefly back into visibility right as the animation completes, just as the destination view controller achieves its final position.
I'm also getting a warning about Unbalanced calls to begin/end appearance transitions which I'm still working on fixing-- I don't know if they're related.
Does anyone see anything here that jumps out as not quite right that would cause a flicker?
I then just assigned a button to do a custom segue via storyboard editor.
-(void)perform
{
UIViewController *source = self.sourceViewController;
UIViewController *destination = self.destinationViewController;
[source.view addSubview:destination.view];
destination.view.transform = CGAffineTransformMakeRotation(M_PI / 2);
[UIView animateWithDuration:0.5 delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
destination.view.transform = CGAffineTransformMakeRotation(0);
}completion:^(BOOL finished){
[destination.view removeFromSuperview];
[source presentViewController:destination animated:NO completion:NULL];
}];
}
Take out the removeFromSuperview.

ViewContoller animation from top to bottom

I m developing a E-commerce mobile application in iOS. I need to know how to move from one UIViewController to another UIViewController with slide animation from top to bottom.
I am using Storyboard.
App needs to works in ios6 and ios7.
Below is the code i used for tranitioning UIViewController
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
MenuViewController *viewController =
(MenuViewController *)
[storyboard instantiateViewControllerWithIdentifier:#"menupage"];
[self.navigationController pushViewController:viewController animated:NO];
Below is the code I tried for a turn page effect and it worked fine. I need the same thing as below for a slide top to bottom
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:viewController animated:YES];
[UIView commitAnimations];
The another method
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
MenuViewController *viewController = (MenuViewController *)[storyboard instantiateViewControllerWithIdentifier:#"menupage"];
MenuViewController *viewController1 = (MenuViewController *)[storyboard instantiateViewControllerWithIdentifier:#"menupage"];
[self.view addSubview:viewController.view];
viewController.view.frame=CGRectMake(0,480,320,480);
[UIView animateWithDuration:1
animations:^{
viewController.view.frame=CGRectMake(0,0,320,480);
}
completion:^(BOOL fin){
if (fin)
{
[self.navigationController pushViewController:viewController animated:NO];
[self.navigationController pushViewController:viewController1 animated:NO];
}
}];
Here i get animation in success manner.But i need to load same view controller twice.One is for animation and another one is for normal ViewController Load.If i didnt load second method i get some problem in nextviewController button actions.
Thanks in Advance
Sam.P
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp
forView:self.navigationController.view cache:NO];
instead of using UIViewAnimationTransitionCurlUp use UIViewAnimationCoverVertical
or simply without any view animations, just change a single line.
[self.navigationController presentViewController:viewController animated:YES completion:NULL];
FYI #MaheThiru the push only gives u to and fro transition and for push u need navigation controller. the other transitions like coververtical, pagecurl, crossdissolve and fliphorizontal are provided by modal transition(without navigation controller) which we write as
[self presentViewController:viewController animated:YES completion:NULL];
and i got a small doubt here y r u writing
animated:NO
change it to
animated:YES
maybe it will solve the problem. try it once.
Happy coding

UINavigation Bar not visible in animation of custom unwind segue

I am using a custom unwind segue in a navigation controller, in the animation of the segue the navigation bar is not visible during the animation, when the animation ends the navigation bar 'pops'. ¿How can i retain the visibility of the navigation bar during the animation?
More details:
I have a button in the navigation bar that calls modal view this animation performs as expected, the new view has a button to trigger the unwind segue animation the view to grow and disappear, while this animation is performing the Navigation Bar in the destination view controller is not visible until the animation is finished.
This is the code i'm using for the custom segue.
- (void) perform {
UIViewController *sourceViewcontroller = self.sourceViewController;
UIViewController *destinationViewcontroller = self.destinationViewController;
[sourceViewcontroller.view.superview insertSubview:destinationViewcontroller.view atIndex:0];
[destinoViewcontroller beginAppearanceTransition:YES animated:YES];
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
origenViewcontroller.view.transform = CGAffineTransformMakeScale(1.5, 1.5);
origenViewcontroller.view.alpha = 0.0;
}
completion:^(BOOL finished){
[destinationViewcontroller.view removeFromSuperview];
[sourceViewcontroller dismissViewControllerAnimated:NO completion:NULL];
}];
}
Ok, so i think i got it, what i did was inserting the whole navigation controller view in the superview of the source view and removing the code to remove the destination view from the superview and setting to YES the option of dismissViewControllerAnimated like this:
- (void) perform {
UIViewController *origenViewcontroller = self.sourceViewController;
UIViewController *destinoViewcontroller = self.destinationViewController;
[origenViewcontroller.view.superview insertSubview:destinoViewcontroller.navigationController.view atIndex:0];
[UIView animateWithDuration:0.4
delay:0.0
options:UIViewAnimationOptionCurveEaseInOut
animations:^{
origenViewcontroller.view.transform = CGAffineTransformMakeScale(2.0, 2.0);
origenViewcontroller.view.alpha = 0.0;
}
completion:^(BOOL finished){
[origenViewcontroller dismissViewControllerAnimated:YES completion:NULL];
}];
}
I'm still not sure if this is the correct way to do it.
You could embed the destinationViewController in a UINavigationController too and set your segue from the sourceViewController to the Navigation Controller.

change transition of navigationcontroller ios

In the typical viewcontroller transition both views, the disappear and appear view are moving, but now I want to create a custom animation where you throw the event to change of view, the view that will disappear, just hide without transition and animation, and the view will appear continue with the same transition.
then the problem here is I have navigation bar and I don't know, how can I create a custom transition of navigation bar?,
can you help me to know how to change or remove the transition of navigation controller.
I've try it but it only add other transition and don't remove the base transition.
For Push:
MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.navigationController pushViewController:nextView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
For Pop:
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:transition forView:self.navigationController.view cache:NO];
}];
[self.navigationController popViewControllerAnimated:NO];
any ideas? thanks :D
You can just use add as subview and have title bar to mimic like navigation controller.
MainView *nextView = [[MainView alloc] init];
//setup frame
nextView.view.frame = xxx;
[self.view addSubview:nextView.view];
Remove using [nexView.view removeFromSuperView];
OR
Just add some view above your current view with default hidden and set hidden NO on some action or call bringSubviewFront method if you want to keep view below and bring in front on some action.

Use presentModalViewController but with modeUIViewAnimationTransitionCurlUp

How is it possible that I change the transition for presenting a modal view controller. Is it possible that the presenting transition is using the default UIModalTransitionStyle....
UIModalTransitionStyleCoverVertical = 0,
UIModalTransitionStyleFlipHorizontal,
UIModalTransitionStyleCrossDissolve,
UIModalTransitionStylePartialCurl,
but the dismiss transition is using the UIViewAnimationTransitionCurlUp transition. Important is that I don't want to use the UIModalTransitionStylePartialCurl it should be the CurlUp one.
Sadly the following code doesn't work:
[UIView transitionFromView:self.view toView:self.parentViewController.parentViewController.parentViewController.view duration:1.0 options:UIViewAnimationTransitionCurlUp completion:^(BOOL finished) {....}];
Maybe it has something to do that the view controller is displayed in modal mode.
It would be nice if someone can help.
It feels kludgy, but you can do this by animating the transition of adding your destination view controller's view, but on the completion of that, you immediately remove it again and then properly transition to it via the presentViewController (this time without animation, since the visual effect has already been rendered).
I do this in a subclassed custom UIStoryboardSegue (you didn't say NIBs or storyboard, but the concept is the same):
- (void)perform
{
UIViewController *src = self.sourceViewController;
UIViewController *dst = self.destinationViewController;
[UIView transitionWithView:src.navigationController.view
duration:0.75
options:UIViewAnimationOptionTransitionCurlUp | UIViewAnimationOptionCurveEaseInOut
animations:^{
[src.navigationController.view addSubview:dst.view];
}
completion:^(BOOL finished){
[dst.view removeFromSuperview];
[src presentViewController:dst animated:NO completion:nil];
}];
}
Clearly, if your source view controller doesn't have a navigation controller, you would replace those "src.navigationController.view" with just "src.view". But hopefully this gives you the idea.
And, anticipating the logical follow-up question, when dismissing the view controller, I have a button hooked up to an IBAction:
- (IBAction)doneButton:(id)sender
{
[UIView transitionWithView:self.view.superview
duration:0.75
options:UIViewAnimationOptionTransitionCurlDown
animations:^{
[self dismissViewControllerAnimated:NO completion:nil];
}
completion:nil];
}

Resources