【发布时间】:2014-03-23 20:28:51
【问题描述】:
我有一个 UIViewController 可以由两个不同的其他视图呈现。这是一个搜索表单,对两种视图的行为完全相同。
假设 View1 和 View2 可以执行显示 SearchView 实例的 segue。我怎么知道哪个视图呈现了 SearchView 以便我可以执行与相应操作相关联的展开转场?
由于 View1 和 View2 都是 TabView,我不想在它们每个中都使用 navigationController,因为我发现它对于一个简单的任务来说有点过于强大了。
在这个例子中:
View1.m
-(IBAction)didClickButton:
{
[self performSegueWithIdentifier:@"searchSegue1"];
}
View2.m
-(IBAction)didClickButton:
{
[self performSegueWithIdentifier:@"searchSegue2"];
}
SearchView.m
// Here is where I should know which segue to call
if (***ConditionToSegue1***)
[self performSegueWithIdentifier:@"unwindToSegue1"];
else if (***ConditionToSegue2***)
[self performSegueWithIdentifier:@"unwindToSegue2"];
这是什么条件?最好的方法是在 prepareForSegue 方法中设置 SearchView 的属性,告诉我发起调用的视图是什么?请记住,我不想使用 NavigationController。
最好的问候
【问题讨论】:
标签: ios iphone objective-c uistoryboard uistoryboardsegue