Swift:如何在使用SWRevealViewController时执行后退操作

时间:2016-10-31 11:02:33

标签: ios iphone swift xcode8 swrevealviewcontroller

我在我的应用的HomeVC上使用 SWRevealViewController 作为SideMenu栏选项。

当用户点击HomeVC中的任何按钮时,它会导航到另一个屏幕( PushViewController )。在这个新的视图控制器中,我显示了自定义后退按钮。

现在,当用户点击此后退按钮时,视图应该加速到HomeVC。以下是我使用的代码:

HomeViewController:

@IBAction func recharge_Mobile(_ sender: UIButton) {

   let objRechargeMobileViewController = self.storyboard?.instantiateViewController(withIdentifier: "idRechargeMobileViewController") as! RechargeMobileViewController
   self.navigationController?.pushViewController(objRechargeMobileViewController, animated: true)
    }

RechargeViewController:

     override func viewDidLoad() {
            super.viewDidLoad()

            self.navigationItem.leftBarButtonItem = UIBarButtonItem(image:UIImage(named:"back.png"), style: .plain, target: self, action: #selector(btnBack_Clicked()))

            self.navigationController?.navigationBar.tintColor = UIColor.black
  . . .   
  }

     @IBAction func btnBack_Clicked() {
           /* for controller in self.navigationController!.viewControllers as Array {
                if controller.isKind(of: ViewController()) {
                    self.navigationController?.popToViewController(controller as! ViewController, animated: true)
                    break
                }
            } */

            self.navigationController?.popViewController(animated: true)
        }

我哪里出错?

0 个答案:

没有答案