Push ViewController from Right To Left with UINavigationController

后端 未结 11 1781
名媛妹妹
名媛妹妹 2020-12-02 11:27

As everyone know the UINavigationController push a ViewController from Left To Right, is there a way to push the View from Right To Left? like the animation for the back but

11条回答
  •  生来不讨喜
    2020-12-02 11:52

    You can create a NSMutableArray from the navigationController's array of viewcontrollers and insert new viewController before the current one. Then set the viewControllers array without animation and pop back.

    UIViewController *newVC = ...;
    NSMutableArray *vcs =  [NSMutableArray arrayWithArray:self.navigationController.viewControllers];
    [vcs insertObject:newVC atIndex:[vcs count]-1];
    [self.navigationController setViewControllers:vcs animated:NO];
    [self.navigationController popViewControllerAnimated:YES];
    

提交回复
热议问题