3

我已经设置了我的向下钻取表的 Xcode 故事板,以分支到两个详细视图。

我希望它根据我在表格视图中点击的预算对象的状态来选择其中一个。如果预算对象尚未初始化,我想继续初始化视图。如果它已被初始化,我希望它继续到详细视图。

到目前为止,这就是我所拥有的......

- (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”seguebudget.initialized = false我如何实现一种 performSegue:withIdentifier:方法来做到这一点?

4

1 回答 1

4

performSegueWithIdentifier您需要根据您的情况触发该方法。

就像是:

if ([self.budgetPlan.budgets count] > 0) {
    [self performSegueWithIdentifier@"showDetailsOfBudget"];
} else {
    [self performSegueWithIdentifier@"createBudget"];
}
于 2012-03-27T12:10:42.073 回答