XCode / iOS - AppDelegate中ViewController的参考

时间:2012-06-06 16:25:35

标签: ios cocoa-touch

在我看来,我的iPad应用程序加载了Storyboard文件以及它自己的ViewController。我在plist文件中看到“主故事板文件基本名称”的条目。

来自我曾经在Xcode中创建“空应用程序”的背景,然后我将创建UIViewController和nib文件,在

中实例化
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

并添加到视图中,我引用(变量)此ViewController对象

现在在这个“单视图应用程序”中,我没有看到任何对基于Storyboard的ViewController的引用,我需要有一个引用来做一些工作。请指教。

1 个答案:

答案 0 :(得分:4)

查看此问题,了解有关通过故事板访问视图控制器的一些示例代码 - Accessing a view controller created through Storyboard using the App Delegate

对于基本答案,您应该能够引用“window”属性。您应该能够使用“窗口”引用的属性来引用其他视图。 UIWindow附加了一个“rootViewController”属性。

UIWindow文档 - http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIWindow_Class/UIWindowClassReference/UIWindowClassReference.html