2016-08-12 65 views
0

我想問,如果我有一個uitableviewcell,我需要做檢查以滿足條件,然後只對不同的視圖執行不同的segue,如何做到這一點?例如:一個uitableviewcell可以查看2個視圖嗎?

if subCat[indexPath.row] == ""{ 

     performSegueWithIdentifier("A", sender: self) 

    }else{ 

     performSegueWithIdentifier("B", sender: self) 

    } 

怎麼辦?我應該如何將它與故事板上的segue連接起來?

+0

是的。將第二個segue連接到* view controller *與第一個相同。你的例子看起來不錯。 –

+0

@ShadowOf那我該怎麼做呢?任何其他方式? – bobo

+0

https://developer.apple.com/library/ios/referencelibrary/GettingStarted/DevelopiOSAppsSwift/Lesson8.html#//apple_ref/doc/uid/TP40015214-CH16-SW1 –

回答

-1

即使您可以通過給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) 
} 
相關問題