我是开发环境中的新手Swift,我有一个问题,我无法摆脱它,我创建了一个popover,里面我有一个" UITableViewController",其中每个单元格必须打开一个" UIViewController"在侧边菜单" SWRevealViewController"问题是:popover正确打开所需的页面" Main"或" Carrello",但左侧的侧面菜单不再打开,返回我" revealViewController()= nil"有人可以帮帮我吗?谢谢。
酥料饼:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.row == 0){
let vc = storyboard?.instantiateViewControllerWithIdentifier("MainController") as! MainController
let navigationController = UINavigationController(rootViewController: vc)
self.presentViewController(navigationController, animated: false, completion: nil)
}
}
MainController:
import Foundation
import UIKit
class MainController: UIViewController {
@IBOutlet weak var menuButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
if revealViewController() != nil {
menuButton.target = revealViewController()
menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}