从UITableView到DetailView的条件段,基于对象状态 [英] Conditional Segue from UITableView to DetailView based on object state
问题描述
我已经设置了我的钻取表的Xcode故事板,分支到两个详细视图。
I've set up the Xcode storyboard of my drill down table to branch out to two detail views.
我想要它根据我在表视图中点击的预算对象的状态。如果预算对象尚未初始化,我想要连接到初始化视图。如果它已经初始化,我想要它到细节视图。
I want it to segue to either one based on the status of the Budget object that I tapped in the table view. If the budget object has not been initialized, I want to to segue to the initializing view. If it has been initialized, I want it to segue to the detail view.
到目前为止,这是我有...
So far, this is what I have...
- (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];
}
}
当然,视图。我想让它使用initializeBudgetsegue当情况是 budget.initialized = false
如何实现 performSegue:withIdentifier:
Of course, this only makes it segue to the detail view. I want it to use the "initializeBudget" segue for when the case is budget.initialized = false
How do I implement a performSegue:withIdentifier:
method to do this?
推荐答案
您需要触发方法 performSegueWithIdentifier
取决于您的情况。
You need to fire off the method performSegueWithIdentifier
depending on your condition.
如下:
if ([self.budgetPlan.budgets count] > 0) {
[self performSegueWithIdentifier@"showDetailsOfBudget"];
} else {
[self performSegueWithIdentifier@"createBudget"];
}
这篇关于从UITableView到DetailView的条件段,基于对象状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!