newbie to ios app coding here so any help would greatly be appreciated.
I have an app that when rotated to landscape opens a side menu automatically and I need it to disable the menu button in the child view of the navigationController. Here's my code.
Navigation controller
import Foundation
class GDNavigationController:UINavigationController{
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
//Send notification when the device is rotated.
NSNotificationCenter.defaultCenter().addObserver(self, selector: "rotated", name: UIDeviceOrientationDidChangeNotification, object: nil)
}
func rotated(){
/*
Put the code here to access the menu button
*/
if(UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation))
{
//disable the menu button here
self.revealViewController().setFrontViewPosition(FrontViewPosition.Right, animated: false)
}
if(UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation))
{
//enable the 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 with different viewControllers based on which menu item is selected. The different navigationControllers share the same subclass but I never know which viewController is loaded, this is what I need to find out and how to access the button in that viewController.
Can anyone help?
So I figured it out, change my navigation controller to this
import Foundation class GDNavigationController:UINavigationController{
}