【问题标题】:Warning window hierarchy when loading delegate加载委托时警告窗口层次结构
【发布时间】:2023-03-16 02:22:01
【问题描述】:

今天我更新了我的 Xcode 并开始为新的 iPhone 5 屏幕更新我的应用程序。

我突然注意到,每次从屏幕 A 转到屏幕 B 时,我都会收到以下警告:

警告:尝试在 谁的视野不在窗内 等级制度!

// 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;
        }            
    }
}

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

我浏览了网络,有些人谈论将代码从 viewDidLoad 移动到 viewAppear,但我认为这不适用于这种情况。

【问题讨论】:

  • 它实际上可能与 viewDidLoad 与 viewDidAppear:animated 有关,因为当视图加载后,它不一定在层次结构中。尝试将您的 presentViewController 代码移动到 viewWillAppear:animated 看看会发生什么...
  • 您好,prepareForSegue 方法在您点击按钮时执行。我没有从任何 viewDid 方法或其他任何地方手动调用。这是一个“UIStoryboardSegue”

标签: ios xcode delegates warnings hierarchy


【解决方案1】:

好吧,我想通了。

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

现在我修好了:

它再次正常工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-27
    • 1970-01-01
    • 1970-01-01
    • 2014-11-17
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多