2012-03-27 56 views
3

我已经设置了我的向下钻取表的Xcode storyboard以分支到两个详细视图。基于对象状态的从UITableView到DetailView的有条件Segue

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

到目前为止,这是我...

- (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:方法来执行此操作?

回答

4

根据您的情况,您需要关闭方法performSegueWithIdentifier

喜欢的东西:

if ([self.budgetPlan.budgets count] > 0) { 
    [self [email protected]"showDetailsOfBudget"]; 
} else { 
    [self [email protected]"createBudget"]; 
} 
+1

通过删除您当前攻火,并有SEGUE从视图控制器去代替对象SEGUE做到这一点。然后使用原始对象上的操作触发的自定义函数。 – lnafziger 2012-03-27 14:06:23