How to close the SideBar menu manually when using SWRevealViewController ( ios)
Solution 1
I just figured out the answer. I just use the following code to hide the side bar.
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
[self.revealViewController revealToggleAnimated:YES];
}
}
Solution 2
The correct answer is:
self.revealViewController().revealToggle(animated: true)
Solution 3
If anyone is looking for a swift
version, just use this single line:
self.revealViewController().revealToggleAnimated()
Solution 4
if the sidebar on left using:
self.revealViewController().revealToggle(animated: true)
if was on the right using:
self.revealViewController().rightRevealToggle(animated: true)
moni_sind
Updated on June 25, 2022Comments
-
moni_sind about 2 years
I am trying to implement a
SideBar
/ slide out menu using theSWRevealViewController
. I have a bunch of menus. One of the menu is to get app version info. So When I click on the cell, AnAlertView
displays the version number and on pressing the OK button I would like to close/hide theSideBar
menu and return to the pervious view(front controller). For example, if I am on log in controller and I press the settings button to reveal the side bar and I choose version menu fromTableView
cells, a pop will open displaying version# and when I press Ok, theSideBar
should close and return to the login screen without me having to tap the settings button again or swiping to return. How can I return to the login screen when I press OK on the alert view.- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex { // the user clicked OK if (buttonIndex == 0) { //close the side bar and return to front view controller } }
-
kike0kike about 7 yearsFirt yo must to check if your menu is open -> if (revealViewController().frontViewPosition == FrontViewPosition.right)