一个uitableviewcell可以查看2个视图吗?
问题描述:
我想问,如果我有一个uitableviewcell,我需要做检查以满足条件,然后只对不同的视图执行不同的segue,如何做到这一点?例如:一个uitableviewcell可以查看2个视图吗?
if subCat[indexPath.row] == ""{
performSegueWithIdentifier("A", sender: self)
}else{
performSegueWithIdentifier("B", sender: self)
}
怎么办?我应该如何将它与故事板上的segue连接起来?
答
即使您可以通过给viewController 1和“B”提供故事板标识符“A”来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)
}
是的。将第二个segue连接到* view controller *与第一个相同。你的例子看起来不错。 –
@ShadowOf那我该怎么做呢?任何其他方式? – bobo
https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson8.html#//apple_ref/doc/uid/TP40015214-CH16-SW1 –