Need assistance regarding transitionFromView:toView:duration:options:completion:

前端 未结 2 2005
故里飘歌
故里飘歌 2020-12-22 05:51

Regarding transitionFromView:toView:duration:options:completion: Apple doc says this in last few lines:

This method modifies the views in their view h

相关标签:
2条回答
  • 2020-12-22 06:04

    When we use transitionFromView:toView:duration:options:completion: we are only bringing toView up in view hierarchy. but Apple says we should handle updating of ViewControllers which are parent of these views.

    Maintaining viewcontroller in navigationcontroller stack...

    For .ex: if You have TabController in your application,

    somewhere at tabIndex two you required to show view of viewcontroller at tabindex 1, then you should update your tabIndex when you will use transitionfromview method

    [UIView transitionFromView:fromView 
                            toView:toView 
                          duration:0.5 
                           options:(controllerIndex > tabBarController.selectedIndex ? UIViewAnimationOptionTransitionCurlUp : UIViewAnimationOptionTransitionCurlDown)
                        completion:^(BOOL finished) {
                            if (finished) {
                                tabBarController.selectedIndex = controllerIndex;
                            }
                        }];
    
    0 讨论(0)
  • 2020-12-22 06:11

    The statement "it is your responsibility to update the view controller appropriately to handle the change." it meant that you have to appropriately call view hierarchy delegate methods such as:

    - (void)viewDidLoad;
    - (void)viewDidUnload;
    - (void)viewWillAppear;
    - (void)viewDidDisappear;
    

    And other methods that are responsible for proper view management.

    Here are some examples.

    0 讨论(0)
提交回复
热议问题