Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to close the SideBar menu manually when using SWRevealViewController ( ios)

I am trying to implement a SideBar / slide out menu using the SWRevealViewController. I have a bunch of menus. One of the menu is to get app version info. So When I click on the cell, An AlertView displays the version number and on pressing the OK button I would like to close/hide the SideBar 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 from TableView cells, a pop will open displaying version# and when I press Ok, the SideBar 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
    }
}
like image 559
moni_sind Avatar asked Oct 24 '14 20:10

moni_sind


2 Answers

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];

   }
}
like image 109
moni_sind Avatar answered Sep 22 '22 15:09

moni_sind


The correct answer is:

self.revealViewController().revealToggle(animated: true)
like image 33
Nupur Sharma Avatar answered Sep 20 '22 15:09

Nupur Sharma