有条件的从UITableView到基于对象状态的DetailView

我已经创build了我的向下钻取表的Xcode storyboard来分支到两个细节视图。

我希望它根据我在表格视图中点击的预算对象的状态继续执行。 如果预算对象没有被初始化,我想继续到初始化视图。 如果它已被初始化,我希望它继续到详细视图。

到目前为止,这是我有…

- (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]; } } 

当然,这只是让它延续到细节视图。 我希望它使用“initializeBudget”segue当case是budget.initialized = false如何实现performSegue:withIdentifier:方法来做到这一点?

你需要根据你的情况发射方法performSegueWithIdentifier

就像是:

 if ([self.budgetPlan.budgets count] > 0) { [self performSegueWithIdentifier@"showDetailsOfBudget"]; } else { [self performSegueWithIdentifier@"createBudget"]; }