gpt4 book ai didi

iphone - 获取 View Controller 的 StoryBoard 实例

转载 作者:技术小花猫 更新时间:2023-10-29 11:10:51 24 4
gpt4 key购买 nike

没有 Storyboard的例子:

AppDelegate.h

@property (retain, nonatomic) UIViewController *leftController;

AppDelegate.m

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

其他 View Controller :

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

如何在使用 Storyboard时获取 leftController 的实例?

最佳答案

您可以在界面生成器中给 View Controller 一个标识符,然后简单地使用:

UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"myStoryBoardName" bundle:nil];
self.leftController = [mystoryboard instantiateViewControllerWithIdentifier:@"idyouassigned"];

关于iphone - 获取 View Controller 的 StoryBoard 实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13747211/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com