有没有人知道如何有条件地“停止”段转换:
我的表视图单元格表示可以在下钻“详细”视图中查看的产品...或者不能!(这取决于几件事)
现在我的应用认为所有的产品都是“解锁”的:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
ListaProdottiController *prodottiViewController = [segue destinationViewController];
prodottiViewController.blocco = [self.fetchedResultsController objectAtIndexPath:selectedRowIndex];
}此时,如何取消行选择=>下钻?
发布于 2013-03-19 04:26:17
如果你的目标是iOS 6或更高版本,那么我对最干净的方法的了解如下:
-(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。
发布于 2011-10-21 00:37:55
我不知道这是否是正确的方法,但我发现了一个变通方法。
在故事板中,我从视图控制器的状态栏中关联(control+click)一个段。为段指定一个ID (例如: switchSegue)。
现在,通过代码中的一个操作(在我的代码中我使用了一个按钮),我调用:
[self performSegueWithIdentifier:@"switchSegue" sender:sender];这样,您就可以控制是否执行段。试试here和here中帮助我的教程
希望这能有所帮助。
发布于 2012-01-22 21:25:51
我使用了一种更简单、更整洁的方法。
序列图像板
表视图
这种方式看起来更容易实现,也不会改变segues的工作方式。
https://stackoverflow.com/questions/7819796
复制相似问题