【发布时间】:2018-01-19 00:16:11
【问题描述】:
这是上一个问题的继续。
如果我有一个带有 SWReveal 菜单选项的 TableViewController,当我单击第 1 行时,我如何让它呈现 ViewController1、第 2 行 VC2 等。以下代码(感谢 Brandon A)的行为,但我不知道如何告诉它从原始视图控制器交换视图控制器。
根据我读到的内容,不要在 SWReveal 中使用 segue,必须以编程方式完成所有操作。
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
row = indexPath.row
NSLog("didSelectRowAtIndexPath: %d", row)
let frontStoryboard = UIStoryboard(name: "Main", bundle: .main)
let frontVC = frontStoryboard.instantiateInitialViewController()
let rearStoryboard = UIStoryboard(name: "Main", bundle: .main)
let rearVC = rearStoryboard.instantiateInitialViewController()
// Construct the SWRevealViewController with your view controllers
if let revealVC = SWRevealViewController(rearViewController: rearVC, frontViewController: frontVC) {
revealVC.modalTransitionStyle = .crossDissolve // Set segue transition
present(revealVC, animated: true, completion: nil) // Segue to view controller
}
}
【问题讨论】:
标签: uiviewcontroller swrevealviewcontroller