【发布时间】:2013-07-25 10:23:19
【问题描述】:
我创建了一个使用大量容器视图的应用。今天我发现 iOS 5 不支持嵌入式转场(感谢 Xcode 让我知道。) 所以现在我有很多嵌入的 segues 可以在彼此之间传递数据。
我正在使用此代码在 UIView 中加载 ViewControllers,而不是从 IB 中加载容器:
RootViewController:
- (void)viewDidLoad
{
[super viewDidLoad];
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
NewsViewController *news = [storyboard instantiateViewControllerWithIdentifier:@"NewsViewControllerID"];
news.view.frame = self.newsSection.bounds;
[self.newsSection addSubview:news.view];
[self addChildViewController:news];
[news didMoveToParentViewController:self];
// Do any additional setup after loading the view.
}
我怎样才能使用上述方法并仍然将数据传递给 NewsViewController(类似于为 segue 做准备)
我已经尝试在上面插入类似的东西
NewsViewController *news = [storyboard instantiateViewControllerWithIdentifier:@"NewsViewControllerID"];
news.view.frame = self.newsSection.bounds;
news.myLabel.text = @"Test";
[self.newsSection addSubview:news.view];
但标签不会改变。
我更喜欢只传递数据而不使用单例或委托。
谢谢
【问题讨论】:
标签: ios objective-c cocoa-touch