问题描述
我是目标c中的 Storyboarding
的新手,我需要从 UIVIewController
调用方法。在故事板
之前我在 AppDelegate
中初始化 UIViewController
或者只是分配指针在那里,然后简单地从任何类调用方法,访问AppDelegate属性。怎么办故事板
,如果没有 UIViewController
自己初始化?我的应用程序是 UITabBar
应用程序,如果它确实重要。
I'm new to Storyboarding
in objective c and I need to call method from UIVIewController
. Before Storyboarding
I was initializing UIViewController
in AppDelegate
or just assigning pointer there, and then simply call method from any class, accessing AppDelegate properties. How to do It in Storyboarding
, If there are no UIViewController
initializing by myself? My app is UITabBar
application if it does matter.
推荐答案
你可以从您的应用代表获取故事板的根视图控制器。例如:
You can get the root view controller of your storyboard from your app delegate. For example:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UITabbarController *tbc = (UITabbarController *)self.window.rootViewController;
// Do any setup you want to here
// You aren't setting up the controller - just accessing the one that has been set up for you by the storyboard
return YES;
}
这篇关于在故事板中从初始化的UIViewController调用方法 - 目标c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!