ios8 - Accessing item of a navigationController childview in swift -


newbie ios app coding here appreciated.

i have app when rotated landscape opens side menu automatically , need disable menu button in child view of navigationcontroller. here's code.

navigation controller

import foundation class gdnavigationcontroller:uinavigationcontroller{     override func viewwillappear(animated: bool) {         super.viewwillappear(animated)         //send notification when device rotated.         nsnotificationcenter.defaultcenter().addobserver(self, selector: "rotated", name: uideviceorientationdidchangenotification, object: nil)     }      func rotated(){         /*         put code here access menu button         */         if(uideviceorientationislandscape(uidevice.currentdevice().orientation))         {             //disable menu button here             self.revealviewcontroller().setfrontviewposition(frontviewposition.right, animated: false)         }          if(uideviceorientationisportrait(uidevice.currentdevice().orientation))         {             //enable menu button here             self.revealviewcontroller().setfrontviewposition(frontviewposition.left, animated: false)         }     } } 

my viewcontroller code

import foundation class localcollectioncontroller: uicollectionviewcontroller{           @iboutlet var menuviewbutton: uibarbuttonitem!     override func viewdidload() {         menuviewbutton.target = self.revealviewcontroller()         menuviewbutton.action = selector("revealtoggle:")     }   } 

i have different navigationcontrollers load different viewcontrollers based on menu item selected. different navigationcontrollers share same subclass never know viewcontroller loaded, need find out , how access button in viewcontroller.

can help?

so figured out, change navigation controller this

import foundation class gdnavigationcontroller:uinavigationcontroller{

var bbitem = uibarbuttonitem() override func viewdidappear(animated: bool) {     bbitem = self.topviewcontroller.navigationitem.leftbarbuttonitem!  }  override func viewwillappear(animated: bool) {     super.viewwillappear(animated)     //send notification when device rotated.     nsnotificationcenter.defaultcenter().addobserver(self, selector: "rotated", name: uideviceorientationdidchangenotification, object: nil)     self.rotated() }   func rotated(){      if(uideviceorientationislandscape(uidevice.currentdevice().orientation))     {         self.revealviewcontroller().setfrontviewposition(frontviewposition.right, animated: true)         self.bbitem.enabled = false     }      if(uideviceorientationisportrait(uidevice.currentdevice().orientation))     {         self.revealviewcontroller().setfrontviewposition(frontviewposition.left, animated: true)         self.bbitem.enabled = true     }  } 

}


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -