presentViewController在iOS7上不工作,应用程序挂起

presentViewController在iOS7上不工作,应用程序挂起,ios,uiviewcontroller,uinavigationcontroller,grand-central-dispatch,presentviewcontroller,Ios,Uiviewcontroller,Uinavigationcontroller,Grand Central Dispatch,Presentviewcontroller,我使用GCD来确保这在主线程上发生,但即使这样也不能解决问题 - (void)showCat:(NSNotification *)notification { dispatch_async(dispatch_get_main_queue(), ^{ UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; UINavigationController

我使用GCD来确保这在主线程上发生,但即使这样也不能解决问题

- (void)showCat:(NSNotification *)notification {

    dispatch_async(dispatch_get_main_queue(), ^{
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UINavigationController *navVC = [storyboard instantiateViewControllerWithIdentifier:@"Cat"];

            [self presentViewController:navVC animated:YES completion:^{
                //this never happens on iOS7
            }];
    });
}
navVC不是零

在iOS8上运行良好。在iOS7上,应用程序只是挂起。内存使用率持续上升,直到由于内存压力而崩溃


还有什么其他的原因呢?presentViewController在应用程序的其他区域工作正常。此代码在收到通知时调用。

事实证明,在显示的视图控制器的ViewDidLayoutSubView中有一些递归代码。感谢@matt的提示。不确定为什么这在iOS8中不是一个问题,但是问题已经解决了


这表明,即使您面前没有项目的整个代码库,但实际提供建议仍然是有帮助的,而不是简单地从高高在上的位置往下投票。

您将此代码放在哪里了?在视图控制器中…使用调试器!presentViewController会导致其他各种事情发生,如viewDidLoad、ViewWillDisplay:,等等。找出真正的症结所在。听起来你有递归代码。暂停调试器以找到它。还要确保此场景与iOS 7兼容。如果您在故事板中使用大小类,这就是为什么您在这里使用软管。iOS 7中没有尺码等级。谢谢你的提示。比否决票要好得多。我没有使用大小类。viewDidLoad将在导航控制器中调用,但VIEWDIDLEASE不会调用。这是有道理的,因为视图从未出现过。