Is there a way to use UIViewAnimationOptionTransitionCurlUp without it animating the entire screen?
Asked Answered
S

3

7

I have a view controller that has the following hierarchy:

UIViewController
|
|-view
    |-presentView (UIView)
    |-stagedView (UIView)
    |-UIToolbar

I am using the transitionFromView:toView:duration:options:completion: method to animate a page curl up to swap between the presentView and the stagedView. The present and staged view only cover most of the screen and there is a UIToolbar at the bottom. When I use the UIViewAnimationOptionTransitionCurlUp transition, it is animating the whole root view (toolbar included), not just the two views involved.

[UIView transitionFromView:self.presentView
                    toView:self.stagedView 
                  duration:0.5f 
                   options:UIViewAnimationOptionTransitionCurlUp
                completion:^ (BOOL finished) {
                                   if (finished) {
                                      // cleanup code
                                   }}];

Is there a way to only animate the two subviews, leaving the toolbar alone? If so, how?

Shippen answered 14/1, 2011 at 3:41 Comment(0)
V
3

I've been struggling with this issue and the only way I could resolve it is that I put the fromView into another view. In your case the view hierarchy should look like this:

UIViewController
|
|-view
   |-containerView
      |-presentView
   |-stagedView
   |-UIToolBar

The fromView parameter still should point to presentView. Hope this helps.

Vintage answered 30/1, 2011 at 11:44 Comment(0)
S
2

This tutorial explains it perfectly.

http://joris.kluivers.nl/iphone-dev/?p=CurlTransition

Basically, you want to create a container view which will be the view we'll be animating, you could call it containerView. This container view will already have a subview added to it which can fill the entire containerView. Then use the code below when you want to animate to the next view. You remove the present view and add the next view. In the end, you are really transitioning between your containerView. Which itself is being changed after the animation begin statement.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5f];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:containerView cache:NO];
[presentView removeFromSuperview];
[containerView addSubview:nextView];
[UIView commitAnimations];
Subtract answered 18/3, 2011 at 22:5 Comment(0)
R
0

Wayne i suggest you to use the tab bar and then implement its delegate method.I just did it for you

   - (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
    {
        //NSArray *vc= tabBarController.viewControllers;
    //  for (int i = 0; i < [vc count]; i++) {
    //      UINavigationController *nc = [vc objectAtIndex:i];
    //      if (nc == tabBarController.selectedViewController) {
    //          continue;
    //      }
            [UIView beginAnimations:@"animation" context:nil];
            //[self.navigationController pushViewController:nc.topViewController animated:NO]; 
            [UIView setAnimationDuration:1.5];
            [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewController.view cache:NO]; 
            [UIView commitAnimations];
        return TRUE;

    }

Here is just the logic with the tab bar,it only flips the view not the tabbar.So i hope the same you could with ToolBar. Well it will just give you idea.Hope it could help you

Rappel answered 14/1, 2011 at 7:59 Comment(2)
OK, that would be fine, except that the UITabBarController is not appropriate for the application. The design choice I have made is quite appropriate for the application I am writing. TabBarControllers are used for switching between disparate view controllers. The views I wish to swap are complimentary in nature. The toolbar is not for switching between the various views, but for interacting with them, again, making the UITabBarController inappropriate. Thanks, though.Shippen
@Wayne,No problem dear,i thought that you want this in the same way.Ok you can make a try and can play with your code..... You just need to provide the view in forview [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:viewController.view cache:NO]; ,for which you want to have the transition with...Rappel

© 2022 - 2024 — McMap. All rights reserved.