簡體   English   中英

如果我想從在代碼中打開 collectionview 的 tableview 中按下單元格,我該怎么辦?

[英]How can I do if I want to press a cell from a tableview that opens a collectionview in code?

這是我的故事板在此處輸入圖片說明

這是來自最后一個 tableview 的代碼在此處輸入圖片說明

你應該實施

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 
                self.performSegueWithIdentifier("yourIdentifierHereFromStoryboard", sender: yourSender or nil ) }

在 PatientDetailTableViewController 中,您可以實現 tableview 委托的 func:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
    let collectionView = self.storyboard!.instantiateViewControllerWithIdentifier("CollectionViewController") as! CollectionViewController
    self.navigationController?.pushViewController(collectionView, animated: true)
}

並在您的故事板中,記住填寫故事板 ID:“CollectionViewController”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM