【问题标题】:UINavigationController no animations anymoreUINavigationController 没有动画了
【发布时间】:2015-10-30 08:24:22
【问题描述】:

我在 iOS 8 上的 UINavigationController 有一个非常奇怪的问题,也许有人已经遇到过这个问题并且可以解释一下。我有 2 个视图:假设视图 A 和视图 B 我是这样使用它的:

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];

问题是,如果我玩这个 2 分钟,然后像 push-push-push-push-pop 一样重复一遍......有时它会停止动画,无论是 push 还是 pop。 我检查了 1) 它们在弹出到 root 时被释放的视图控制器,2) 我没有收到任何内存警告,3) 导航控制器是窗口的 rootviewcontroller,为什么会出现这个问题?

我找不到任何解释,也许有人已经遇到过这种情况。另外我提到我没有使用自定义动画,只是普通 UIViewController 的普通原生推送和弹出,甚至没有子类化,所以一切都是原生的。

【问题讨论】:

  • 您在日志中收到任何警告吗?如果是,请发布它们,它们可能会有所帮助。谢谢。
  • 您是在设备还是模拟器上进行测试?
  • 绝对没有警告我在所有异常上也有断点......有些东西正在禁用我的动画,但那里没有输出任何东西
  • 我也面临同样的问题。运气好吗?
  • 这是关于您使用的自定义动画,检查您是否使用来自系统的正常推送,或者如果您覆盖了动画,然后检查那里的一些内存泄漏或要推送的实际代码和过渡

标签: ios objective-c iphone animation uinavigationcontroller


【解决方案1】:

@kokos8998 尝试使用

@interface AnimatorPushGalleryToGallery : NSObject <UIViewControllerAnimatedTransitioning>

然后在视图 A 中添加这个并控制视图 B 中的所有内容,无论是 A->B 还是 B->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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-05-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-30
    • 1970-01-01
    相关资源
    最近更新 更多