[英]Is there a way to get reference to a viewController in storyboard without instantiating it again?
I have created a ViewController
menu that contains a tableView with selected items. 我创建了一个
ViewController
菜单,其中包含带有选定项的tableView。 I keep it inside a Container outside my navigation controller. 我将其保存在导航控制器外部的Container中。 I need to create that
ViewController
only once and present it from time to time across my app. 我只需要创建一次
ViewController
,然后不时在我的应用程序中展示它。 I know I can save the ViewController inside a singleton class in order to use it but I was wondering, is there a better way doing that? 我知道我可以将ViewController保存在单例类中以便使用它,但是我想知道,有没有更好的方法呢?
The only methods in <UIKit/UIStoryboard.h>
are <UIKit/UIStoryboard.h>
中唯一的方法是
+ (UIStoryboard *)storyboardWithName:(NSString *)name bundle:(NSBundle *)storyboardBundleOrNil;
- (id)instantiateInitialViewController;
- (id)instantiateViewControllerWithIdentifier:(NSString *)identifier;
so I don't believe you be able to get a view controller from the storyboard without instantiating a new one. 因此,我认为您不实例化新故事板就无法从情节提要中获取视图控制器。
You could make a singleton class, or keep a reference around in your AppDelegate, whichever suits your needs best. 您可以创建一个单例类,或者在AppDelegate中保留一个引用,以最适合您的需求。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.