加载委托时的警告窗口层次结构

Jua*_*lez 7 xcode delegates warnings hierarchy ios

今天我更新了我的Xcode并开始更新我的应用程序以用于新的iPhone 5屏幕.

我突然注意到每次从屏幕A到屏幕BI都会收到此警告:

警告:尝试显示其视图不在窗口层次结构中!

// This delegate method prepares the segue from Screen A (DilemmaViewController) to Screen B (OptionsViewController)
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    // Executes the following "if" statement if the user wants to add new options
    if ([segue.identifier isEqualToString:@"AddOptions"]) 
    {
        UINavigationController *navigationController = segue.destinationViewController;
        OptionsViewController *controller = (OptionsViewController *)navigationController.topViewController;
        controller.delegate = self;

        // If the user has already put some inputs on the form we send them through the segue
        if ([edit count] > 0){            
            controller.edit = edit;
        }            
    }
}
Run Code Online (Sandbox Code Playgroud)

自从我的应用程序的第一个版本以来,我没有碰过这个,所以我不确定这里会发生什么.

我环顾网络,有些人谈论将代码从viewDidLoad转移到viewAppear,但我不认为这适用于这种情况.

Jua*_*lez 4

好吧,我想通了。

我的问题是,在某些时候我犯了一个错误,将 Touch Up Inside 事件连接到原始(且正确的)segue 事件之上:

在此输入图像描述

现在我修复了它:

在此输入图像描述

它又可以正常工作了。