3

In loginVC i have created a button on clicking it, it goes to main tabbarcontroller thru segue like this..

@IBAction func btnLoginPressed(sender: AnyObject) {
 self.performSegueWithIdentifier("logintoMain", sender: self)    
}

is succesfully goes to tabbarmainVC but after that the swRevealviewController is getting nil.. and the sliding not working here. why?

class MaintabbarController: UIViewController{

@IBOutlet weak var slideBtn: UIBarButtonItem!

override func viewDidLoad() {
    super.viewDidLoad()

    // Do any additional setup after loading the view.
    if self.revealViewController() != nil{
        slideBtn.target = self.revealViewController()
        slideBtn.action = #selector(SWRevealViewController.revealToggle(_:))
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
    }    
}

Edited

I have tried this code also on login button click to go to the mainTabbarvc. Now its working fine . Actually i have to push the revealviewController than only it will be active..

 @IBAction func btnLoginPressed(sender: AnyObject) {
  let sb = UIStoryboard(name: "Main", bundle: nil)
  let vc =sb.instantiateViewControllerWithIdentifier("yourtabbarvcidentifier") as! UITabBarController
   vc.selectedIndex = 0
 // self.presentViewController(vc, animated: true, completion: nil)
    self.revealViewController().pushFrontViewController(vc, animated: true)
  }
PRADIP KUMAR
  • 489
  • 1
  • 9
  • 31
  • Did you configure your storyBoard to work with SWRevealViewController properly? I mean sw_front segue identifier, sw_rear segue identifier etc? – Reinier Melian Jul 14 '16 at 18:42
  • yes all are correctly working . only problem came afterreturmimg back to this page thru segue on clicking any button of viewcontroller@ReinierMelian – PRADIP KUMAR Jul 14 '16 at 20:24

1 Answers1

1

Try adding it to this function and see what happens:

override func viewWillAppear(animated: Bool) {
    if self.revealViewController() != nil{
    slideBtn.target = self.revealViewController()
    slideBtn.action = #selector(SWRevealViewController.revealToggle(_:))
    self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
 }
}

This will appear when the view is active.

Konsy
  • 306
  • 3
  • 22