Modal ViewController弹出没有动画,bug?

时间:2013-05-16 12:38:29

标签: iphone ios objective-c

有时当我使用:[self presentViewController:viewController animated:YES completion:nil];或者即使模态segue处理过渡时,它也会弹出而没有任何过渡,使它看起来很难看。虽然很少见,但是当这种情况发生时,每个模态VC都会做同样的事情,无论它在何处/如何调用。当我重新启动应用程序时,问题就出现了,就是这样,它不会再发生一段时间了。虽然有些奇怪,但在解雇VC时会有一个转变。这是一个错误吗?

感谢您的帮助,问候,
麦克

更新:我想我找到了原因。当我提出这样的教程视图时,这个bug会影响大多数模态VC和所有Segue模态VC:

    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    TutorialViewController *tutPopUp = [[TutorialViewController alloc] init];
    self.tabBarController.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentModalViewController:tutPopUp animated:NO];

我认为问题在于self.tabBarController.modalPresentationStyle = UIModalPresentationCurrentContext;会影响整个标签栏。一旦我加载了这个特定的VC,我可以设置的默认值是什么?

已回复:在阅读完Apple Docs后,我发现默认modalPresentationStyleUIModalPresentationFullScreen,因此在使用其他presentationStyle后将其设置为固定。< / p>

2 个答案:

答案 0 :(得分:1)

如果您在设备上遇到这种情况,我会想象正在执行一些密集的CPU任务,这会导致主线程上的阻塞和卡顿。如果它在模拟器上,那么你的Mac可能会在那一刻负担过重。

你说的一件事让我对你的记忆管理感到好奇。你说如果你退出应用程序,问题就会消失一段时间。让我觉得你有一个影响性能的内存泄漏。你在使用ARC吗?

因为你明确地要求动画,所以没有理由在UIKit级别上没有动画。

答案 1 :(得分:1)

问题出现在一些代码中,我曾经在我的应用程序的其他地方显示另一个VC:

    [tableView deselectRowAtIndexPath:indexPath animated:NO];
    TutorialViewController *tutPopUp = [[TutorialViewController alloc] init];
    self.tabBarController.modalPresentationStyle = UIModalPresentationCurrentContext;
    [self presentModalViewController:tutPopUp animated:NO];

问题出在这里:self.tabBarController.modalPresentationStyle = UIModalPresentationCurrentContext;因为这会影响我应用中的整个标签栏,并将演示文稿样式更改为没有动画的样式。我发现默认modalPresentationStyleUIModalPresentationFullScreen,因此在使用其他presentationStyle后将其设置为固定我的问题。

相关问题