Objective c 基于对象状态从UITableView到DetailView的条件顺序
我已经设置了向下钻取表的Xcode序列图像板,以扩展到两个细节视图 我希望根据我在表视图中点击的预算对象的状态将其转换为任意一个。如果预算对象尚未初始化,我想转到初始化视图。如果它已经初始化,我希望它转到细节视图 到目前为止,这就是我所拥有的Objective c 基于对象状态从UITableView到DetailView的条件顺序,objective-c,ios,xcode,cocoa-touch,uistoryboardsegue,Objective C,Ios,Xcode,Cocoa Touch,Uistoryboardsegue,我已经设置了向下钻取表的Xcode序列图像板,以扩展到两个细节视图 我希望根据我在表视图中点击的预算对象的状态将其转换为任意一个。如果预算对象尚未初始化,我想转到初始化视图。如果它已经初始化,我希望它转到细节视图 到目前为止,这就是我所拥有的 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { /* When a row is selected, the segue creates th
- (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:
方法来执行此操作?您需要根据您的条件触发方法performSegueWithIdentifier
比如:
if ([self.budgetPlan.budgets count] > 0) {
[self performSegueWithIdentifier@"showDetailsOfBudget"];
} else {
[self performSegueWithIdentifier@"createBudget"];
}
要做到这一点,请从当前正在点击的对象中删除segue以激活它,并将segue从视图控制器中移除。然后使用由原始对象上的操作触发的自定义函数。