UINavigationController no animations anymore

时间:2015-08-07 01:43:56

标签: ios objective-c iphone animation uinavigationcontroller

I have a very weird problem with the UINavigationController on iOS 8, maybe someone encountered this already and can shed some light. I have 2 views: let's say view A and view B I am using it like this:

view A [self.navigationController pushViewController:vc animated:YES];

push to a new view B [self.navigationController pushViewController:vc animated:YES];

push to a new view B [self.navigationController pushViewController:vc animated:YES];

push to a new view B [self.navigationController pushViewController:vc animated:YES];

push to a new view B [self.navigationController pushViewController:vc animated:YES];

push to a new view B [self.navigationController pushViewController:vc animated:YES];

return to view A [self.navigationController popToRootViewControllerAnimated:YES];

The problem is that if I play with this for 2 min and go through this like push-push-push-push-pop and again... at some time it stops animating, for either push and pop. I checked the 1) view controllers they get deallocated on the pop to root, 2) I don't receive any memory warnings, 3) the navigation controller is the rootviewcontroller of the window so why this problem?

I can't find any explanation maybe someone has encountered this already. Also I am mentioning I am not using custom animations, just the plain native push and pop of a normal UIViewController, not even subclassing that so everything is plain native.

1 个答案:

答案 0 :(得分:0)

@ kokos8998尝试使用

@interface AnimatorPushGalleryToGallery : NSObject <UIViewControllerAnimatedTransitioning>

然后在视图A中添加此项并将控制视图B中的所有内容A-&gt; B或B-&gt; A(或者如果您需要更多自定义,则在B中添加相同的委托)

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.navigationController.delegate = self;
}

- (nullable id <UIViewControllerAnimatedTransitioning>)navigationController:(UINavigationController *)navigationController
                                            animationControllerForOperation:(UINavigationControllerOperation)operation
                                                         fromViewController:(UIViewController *)fromVC
                                                           toViewController:(UIViewController *)toVC
{
    if(operation == UINavigationControllerOperationPush)
        return [AnimatorPushGalleryToGallery new];
    else if(operation == UINavigationControllerOperationPop)
        return [AnimatorPopGalleryToGallery new];

    return nil;
}