9

没有故事板的示例:

AppDelegate.h

@property (retain, nonatomic) UIViewController *leftController;

AppDelegate.m

self.leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];

其他视图控制器:

//This is what I want do to in storyboards
self.viewDeckController.leftController = (AppDelegate*)[[UIApplication sharedApplication] delegate].leftController;

使用情节提要时如何获取 leftController 的实例?

4

2 回答 2

28

您可以在界面生成器中为视图控制器提供一个标识符,然后只需使用:

UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"myStoryBoardName" bundle:nil];
self.leftController = [mystoryboard instantiateViewControllerWithIdentifier:@"idyouassigned"];
于 2012-12-06T15:48:43.370 回答
0

我不确定你是否能得到这个问题的解决方案,但你也可以参考这个问题的答案:

从情节提要中访问视图控制器

于 2015-09-16T12:38:19.600 回答