我已经在我的下钻表中设置了Xcode故事板,以分支到两个详细视图。
我希望它根据我在表格视图中点击的Budget对象的状态来切换到任何一个。如果预算对象尚未初始化,我想要转到初始化视图。如果已经初始化,我希望它能够转向细节视图。
到目前为止,这就是我所拥有的......
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
/*
When a row is selected, the segue creates the detail view controller as the destination.
Set the detail view controller's detail item to the item associated with the selected row.
*/
if ([[segue identifier] isEqualToString:@"showDetailsOfBudget"])
{
NSIndexPath *indexPath = [self.budgetsTable indexPathForSelectedRow];
BudgetDetailsViewController *detailsViewController = [segue destinationViewController];
detailsViewController.budget = [self.budgetPlan.budgets objectAtIndex:indexPath.row];
}
}
当然,这只会使它偏离细节视图。我希望它在案例为budget.initialized = false
时使用“initializeBudget”segue如何实现 performSegue:withIdentifier:
方法来执行此操作?
答案 0 :(得分:4)
您需要根据您的情况启动方法performSegueWithIdentifier
。
类似的东西:
if ([self.budgetPlan.budgets count] > 0) {
[self performSegueWithIdentifier@"showDetailsOfBudget"];
} else {
[self performSegueWithIdentifier@"createBudget"];
}