[英]iOS Swift Segue from TableView Cell without Storyboard
當您單擊tableView的單元格時,執行序列時遇到麻煩。 我根本沒有在應用程序中使用情節提要(已刪除情節提要文件),並且想知道如何執行此Segue。 注意:
我的tableView與顯示它的viewController位於不同的文件中。 所以在我的ViewController中,我有這行:
讓tableView = MyTableView(restaurants_data:餐廳,框架:CGRect(),樣式:.Plain)view.addSubview(tableView)
因此,由於MyTableView.swift是didSelectRowAtIndexPath函數所在的文件,因此我無法執行以下操作
self.navigationController?.showViewController(destinationVC,sender:nil)
那么,假設我使用的是自定義TableView且我的應用程序未使用StoryBoard,那么當用戶單擊單元格時如何執行segue? 在此先多謝
在tableView內為viewController添加一個引用
並在viewController init var controller中初始化它:UIViewController
controller.presentViewController(viewControllerToPresent:UIViewController,動畫:Bool,完成:塊?>)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.