I want to create a slidebar menu in my app (As shown in the image below)
When I click that hamburger icon, it should show a menu as shown below.
I am currently using the SWRevealController, a lib written in Objective C. I created a bridging header and imported the class. This is my current Set up
My initial view which branches to a Menu Controller or the UIViewTable is a SWRevealController, and the segues are subclasses of SWRevealViewControllerSegueSetController. In my Food Item View Controller (the controller where the hamburger navigation exist), I added the following code to activate the slidebar action.
override func viewDidLoad() {
super.viewDidLoad()
//Creating the slidebar Navigation using SWRevealViewController
if self.revealViewController() != nil {
menuButton.target = self.revealViewController()
menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
}
However, when I click the button, it is still not responding. When I did this with my other application, it worked fine. I am not sure why it is not working here
This is the source I used as reference: http://www.appcoda.com/sidebar-menu-swift/
View Controller Full Code
@IBOutlet weak var thumbnail_image: UIImageView!
//@IBOutlet weak var food_detail: UITextView!
@IBOutlet weak var testing: UILabel!
@IBOutlet weak var menuButton: UIBarButtonItem!
var jsonResponseFood: NSArray = NSArray() //API for types of food available
var jsonResponseRecipe: NSArray = NSArray() // API for recipes in food
var selectedFood: foodItem?
var postStr: String?
//Initializing API
let FullRecipeAPIModel = fullRecipeAPIModel()
override func viewDidLoad() {
super.viewDidLoad()
//Creating the slidebar Navigation using SWRevealViewController
if self.revealViewController() != nil {
menuButton.target = self.revealViewController()
menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
}
print(selectedFood?.name as String!)
//testing.text = self.selectedFood?.name
let APIModel = apiModel()
APIModel.delegate = self
FullRecipeAPIModel.delegate = self
APIModel.downloadItems(postString: postStr!)
// Do any additional setup after loading the view.
}
Thank you StackOverflow.