Ali
Ali

Reputation: 1436

UINavigationController — left and right flip animation between pushes and pops when presented via presentViewController

Supposed you've got:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    UIViewController *rootViewController = [[UIViewController alloc] init];
    rootViewController.view.backgroundColor = [UIColor whiteColor];

    [self.window setRootViewController:rootViewController];
    [self.window makeKeyAndVisible];

    UINavigationController *modal = [[UINavigationController alloc] initWithRootViewController:[[PTFrontViewController alloc] init]];
    modal.modalPresentationStyle = UIModalPresentationFormSheet;
    [rootViewController presentViewController:modal animated:YES completion:NULL];

    return YES;
}

whereas PTFrontViewController and PTBackViewController view controllers have nothing interesting for sake of this example.

How could you push an instance of PTBackViewController from PTFrontViewController animating as in UIViewAnimationTransitionFlipFromLeft or UIViewAnimationTransitionFlipFromRight?

I am already well aware of these three things:

  1. this is not exactly how you should make use of presentViewController
  2. there is a good reason for UINavigationController's default animation
  3. there are several answers how to "customize" UINavigationController's default animation while pushing and poping, but if you try the code for your self you will notice that when a view controller is presented via presentViewController there are drop shadows and background views that won't get animated correctly

So please answer taking these things in mind. Thank you.

Upvotes: 0

Views: 1205

Answers (1)

Sulthan
Sulthan

Reputation: 130210

First - forget UINavigationController. If you don't need the default animation, just put a UINavigationBar into your controllers. It will get a little easier.

Second - this is a difficult problem, you can't create such an animation only within the modal controller because the background wouldn't be repainted.

Sincerely, the easist solution I see is too forget the modal controller and just add the view controller as a child of your root controller. Then you can control all the animations but you have to write everything by yourself (including the background fading).

Upvotes: 1

Related Questions