【问题标题】:How to call an AppDelegate method from a UIViewController如何从 UIViewController 调用 AppDelegate 方法
【发布时间】:2021-03-15 09:18:08
【问题描述】:

在我的 appDelegate.m 文件中我有这个方法

- (void) goToRN {
   [RCTKeyWindow().rootViewController dismissViewControllerAnimated:true completion:nil];
}

我想从我的 ConsentViewController.swift 文件中调用此方法,例如:AppDelegate().goToRN()

但我收到此错误:Value of type 'AppDelegate' has no member 'goToRN'

【问题讨论】:

标签: ios swift xcode


【解决方案1】:

您可以从应用程序全局变量中获取它:

NSApp.delegate

【讨论】:

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