我想问一下,如果我有一个uitableviewcell,我需要检查以满足条件然后只执行不同的segue到不同的视图,怎么做?示例如:
if subCat[indexPath.row] == ""{
performSegueWithIdentifier("A", sender: self)
}else{
performSegueWithIdentifier("B", sender: self)
}
怎么做?我应该如何在故事板上将它与segue联系起来?
答案 0 :(得分:-1)
即使您可以通过将viewboard标识符“A”提供给viewController 1并将“B”提供给viewController 2来实现,如果使用导航则推送控制器,否则只需显示viewcontroller。
if subCat[indexPath.row] == "" {
let viewController1 = storyboard.instantiateViewControllerWithIdentifier("A") as! ViewController1
// if navigation controller used.
self.navigationController?.pushViewController(viewController1, animated: true)
// if navigation controller not used.
// self.presentViewController(viewController1, animated: true, completion: nil)
}else{
let viewController2 = storyboard.instantiateViewControllerWithIdentifier("B") as! ViewController2
// if navigation controller used.
self.navigationController?.pushViewController(viewController2, animated: true)
// if navigation controller not used.
// self.presentViewController(viewController2, animated: true, completion: nil)
}