我从UITableviewcell.swift
创建了一个新的UITableView
,我想使用提醒按钮将UITableView
推送到其他视图。
我尝试使用instantiateViewController
的某种方法,如下所示:
let sb: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = sb.instantiateViewController(withIdentifier: "MyViewController")
我试试:
self.navigationController?.pushViewController
(uitableviewcell没有成员navigationController)self.window?.rootViewController?
替换Self
,但它没用(我的RootView
是SWRevealViewController
)我该怎么做?
答案 0 :(得分:0)
这对您有帮助
override func tableView(tableView: UITableView!, didSelectRowAtIndexPath path: NSIndexPath!) {
let secondViewController = self.storyboard.instantiateViewControllerWithIdentifier("SecondViewController") as SecondViewController
self.navigationController.pushViewController(secondViewController, animated: true)
}
答案 1 :(得分:0)
最后,问题已经解决了(对我来说:D)
let sb: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let frontVC = sb.instantiateViewController(withIdentifier: "myVC1")
let frontNav = UINavigationController(rootViewController: frontVC)
let rearVC = sb.instantiateViewController(withIdentifier: "myVC2")
let rootVC = SWRevealViewController(rearViewController:rearVC ,frontViewController:frontVC)
self.window?.rootViewController = rootVC