簡體   English   中英

如何從 UIViewController 調用 AppDelegate 方法

[英]How to call an AppDelegate method from a UIViewController

在我的appDelegate.m文件中,我有這個方法

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

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

但我收到此錯誤: Value of type 'AppDelegate' has no member 'goToRN'

您可以從應用程序全局變量中獲取它:

NSApp.delegate

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM