在两个视图控制器之间实现segue时如何使用segue对象更改目标视图控制器的属性?文档说这可以在prepareForSegue:sender:方法中完成.我尝试过但不是没有成功
Dar*_*ndu 13
Dunno,如果你仍然需要一个答案,但这是一个如此孤独的帖子,如果我是正确的,这不再属于NDA.如果我弄错了,请将我的答案放在遗忘之中,所以我们走了:我刚刚完成了一些使用你需要的东西.这是适合我的代码:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"relevantSegueIdentifier"])
{
// [segue destinationViewController] is read-only, so in order to
// write to that view controller you'll have to locally instantiate
// it here:
ViewController *upcomingViewController = [segue destinationViewController];
// You now have a solid reference to the upcoming / destination view
// controller. Example use: Allocate and initialize some property of
// the destination view controller before you reach it and inject a
// reference to the current view controller into the upcoming one:
upcomingViewController.someProperty = [[SomePropertyClass alloc] initWithString:@"Whatever!"];
upcomingViewController.initialViewController = [segue sourceViewController];
// Or, equivalent, but more straightforward:
//upcomingViewController.initialViewController = self;
}
}
Run Code Online (Sandbox Code Playgroud)
这假设someProperty和initialViewController都是目标视图控制器的合成访问器.希望这可以帮助!
我编写了一个教程,提供了使用委托将信息传递给新场景和从场景返回的信息的代码示例,因此检查它应该可以解决您的问题.iOS 5 Storyboard:如何使用Segues,Scenes和静态内容UITableViews
| 归档时间: |
|
| 查看次数: |
16112 次 |
| 最近记录: |