问题描述
有没有人知道如何有条件地停止segue过渡:
Does anyone know how to "stop" a segue transition conditionally:
我的表格视图单元格代表可以在深入详细信息视图中查看的产品......还是不行! (这取决于几件事情)
My table view cells represent products which can be viewed in a drill-down "detail" view... or cannot! (It depends on a couple of things)
现在我的应用认为所有产品都解锁:
Now my App considers all products "unlocked":
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
ListaProdottiController *prodottiViewController = [segue destinationViewController];
prodottiViewController.blocco = [self.fetchedResultsController objectAtIndexPath:selectedRowIndex];
}
此时如何取消行选择=>向下钻取?
How can I cancel the row selection => drilldown, at this point?
推荐答案
如果您的目标是iOS 6或更高版本,那么我对最干净的方法的了解如下:
If you are targeting iOS 6 or greater, then my knowledge of the cleanest way to do this is the following:
-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender
{
if([identifier isEqualToString:@"show"])
{
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
Blocco *blocco = [self.fetchedResultsController objectAtIndexPath:selectedRowIndex];
return [blocco meetRequiredConditions];
}
return YES;
}
哪里有方法
-(BOOL) meetsRequiredConditions;
如果允许向下钻取的几件事情是在你的Blocco类中定义,则返回YES有效。
Defined on your Blocco class returns YES if the "couple of things" which permit a drill-down are valid.
这篇关于如何“取消”一个UIStoryBoardSegue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!