【问题标题】:iOS 5 MainStoryBoard : When linking a view as PUSH, can we set a property?iOS 5 MainStoryBoard:将视图链接为 PUSH 时,我们可以设置属性吗?
【发布时间】:2011-10-21 14:09:06
【问题描述】:
我知道我们仍然可以通过编程来做到这一点,.. 这就是我现在正在使用的(作为 iOS 4)。
旧的方法是初始化你的控制器,设置属性,然后推送。
但在 iOS 5 中,因为主情节提要是设计应用程序的“新”方式。
我想知道是否有任何可能的方法来做同样的事情,设置一个属性然后使用你的 mainstoryboard 中的链接推送?
现在推送很容易,但如果你想设置一个属性,它并不是很有用....
我不知道我是否解释清楚..但它确实是基本的东西。
有人吗?
【问题讨论】:
标签:
properties
ios5
storyboard
pushviewcontroller
【解决方案1】:
您现在可以使用 prepareForSegue: 方法进行任何自定义。您可以获取对即将推送的视图的引用并对其进行操作,类似于此...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Check we're referring to the right segue
if ([[segue identifier] isEqualToString:@"YOUR_SEGUE_NAME_HERE"])
{
// Get reference to the destination view controller
YourViewController *vc = [segue destinationViewController];
// Do your customisations here
}
}
我刚刚写了两篇关于如何做到这一点的博客文章。您可以read it here,它应该(举例说明)如何做到这一点。