SWRevealViewController
SWRevealViewController copied to clipboard
From ViewController navigate back to SWRevealViewController Front Page
As you can see in the picture, there're 3 controllers at the bottom which are (HomeTableViewController, NavigationViewController and NewsViewController)
HomeTableViewController is the Main Page which I'm using the SWRevealViewController and set it as a front page. (sw_front)
After I've selected a row in HomeTableViewController, it can navigate to NewsTableViewController. However, I've added a back button in the NewsViewController to navigate back to the previous page which is HomeTableViewController, I'm not manage to do that with this code.
In the HomeTableViewController navigate to NewsViewController by selected a row
@IBAction func btnBack(sender: AnyObject) { let home = HomeTableViewController() self.presentViewController(home, animated: true, completion: nil) } In the NewsViewController press back button back to previous page
@IBAction func btnBack(sender: AnyObject) { let home = HomeTableViewController() self.presentViewController(home, animated: true, completion: nil) } If I pressed the back button in the NewsViewController, this error appeared.
fatal error: unexpectedly found nil while unwrapping an Optional value self.revealViewController().rearViewRevealWidth = 200 This code has an error and is located in the HomeTableViewController. I hope that someone could help me on this. Thank you.
Delete the navigation controller between Home and News and choose a push segue from Home to News. No needs func btnBack anywhere.
I hope I understood what you want to do. I modified the example RevealControllerStoryboardExample2 accordingly.
https://www.dropbox.com/s/srptix9dddcwrn3/SWRevealViewController-master.zip?dl=0
@iDevelopper Thanks a lot! I did it man. Million of thanks, appreciate. :+1:
https://github.com/iDevelopper/PBRevealViewController
@iDevelopper Hello, Patrick. It seams this solves the problem with segueing back, but what do i do if navigation bar disappears please? Thank you in advance.
Not anderstand. Why does the navigation bar disappear? You can't push a view controller without a navigation controller.
in case i'm deleting NavController between ViewCountroller i m segueing to, and SWR sideMenu -> UINavigationItem i've created disappears in ViewController
You must have a navigation controller for that:
SWR -> UINavigationController -> UIViewController -> UIViewController etc...
Yes, this is exact pattern i'm using. But I got lost :/ Please explain. So i have navigation controller before ViewController, and SW sideMenu segue leads to this NavC. And you've advised to delete it, in order to solve "navigate back" problem.
Please explain
I advised to delete one navigation controller (between home and news) because @jefferyleo had already one before home.
I see. But i'm facing the merely the same problem with segueing back to SWR.
If i may describe my problem in more details, it goes like this: my user logs in at separate viewController -> SWRevealViewController -> sw_front sideMenuLeads segues lead to -> UINavController -> ViewContoller_Z -> VC_Y
So, the problem is - i can't go back to SW_Front_VC from VC_Z
Please advise what am i doing wrong.
p.s. Even if i try method "present(SWR...." it gives me black Screen. p.p.s. in case of sucessfull seguey to SW_Front - i have errors with all the objects that contain parsed values.
Do you mean come back to the first front view controller, not ViewController_Z?
Yes, from the very first ViewControllers, that SideMenu segues to.
I think you should use UINavigationControllerDelegate for that. I will post a sample.
Thank you. I'll be waiting. Thank you again
Sorry for being newb, but where should i look for solution here, please?
I'm not sure to understand your question. It works for you or not? See in RearTableViewController:
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)
Um, i have no problem with getting back to FrontVC via SWmenu. I'm experiencing problem with getting back via "back button" on navigaitonBar. I've implemented your method on my "backBtn", but it gives no result.
Thanks again for your time.
There is nothing special to go back. Because we use the navigation controller of the front view controller, it comes back automatically.
so, what method should i use to load SW_Front? "revealVC" - doesn't work. Please advise.
Sorry but regarding my sample I don't understand your question and/or your problem. Can you show a bit of code?
here it goes.
"class CardsVC: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var menuBtn: UIBarButtonItem! @IBOutlet weak var backBtn: UIBarButtonItem!"
and in viewDidLoad " menuBtn.target = self.revealViewController() menuBtn.action = #selector(SWRevealViewController.revealToggle(_:)) revealViewController().tapGestureRecognizer() revealViewController().panGestureRecognizer()"
So my question is, how can i return to the SW front VC via custom back Button on nav bar. Thank you
Then you have two buttons. menuBtn for opening left side view (sw_rear). And an other one (backBtn). Create an action and call popViewController if your CardsVC has been shown with the frontVC'navigationController.
Could you please explain " if your CardsVC has been shown with the frontVC'navigationController"? How should i connect CardsVC with frontVC'navigationController? Please advise. The following method gives no result :(
"backBtn.target = self backBtn.action = #selector(goBack)" .... "func goBack(_ sender: Any?){ _ = navigationController?.popViewController(animated: true) }"
You can that in my sample I OtherViewController or SettingsViewController are shown with the FrontTableViewController'navigationController, then there is a back button to come back:
Then there is a back button:
Do you want to have another button to show the side menu?
i've deleted default navigation "back button" with following code "self.navigationItem.hidesBackButton = true", coz it overlapped my "menu button" on the left
I really don't understand what you want to do, sorry
I need to go back to SW_front, be using custom "back button" on the right of navigation bar.
Ah ok, then why do you want to push the controllers with navigation controller and not with reveal view controller ?
@IBAction func back(_ sender: UIBarButtonItem) {
let nc = revealViewController().rearViewController as? UINavigationController
let frontNVC = (nc?.topViewController as? RearTableViewController)?.frontNVC
_ = frontNVC?.popViewController(animated: true)
}
in case i'm using pushSegues, instead of "SWRevealViewControllerSeguePushController" - i'm getting error on following code line "revealViewController().tapGestureRecognizer()"
how can i contact you in private, in order to share some more code, please?
@iDevelopper I am having a similar issue with my reveal view controller but kind of confused on what to do. I am a newbe so wanted to make sure Im doing everything properly.
I want to be able to go back to the main view controller from my side menu profile view controller using a back button. I saw your SWPopToFrontSwift 2 file but my reveal controller is set up a bit different.
So when I click on my profile table cell I go into My profile view controller. From there i want to go back to my main view controller not the side menu.
Appreciate any help I can get. thank you
@drmikeb ,
Test the #721 sample and give me a callback.
@iDevelopper,
I set it up exactly the same as in #721. Im getting a sigabrt error when I click on the left menu on simulator. Any ideas why? Thank you for your quick reply
@iDevelopper, I finally figured it out. How would I change the color of the text on the slide out menu?
cell.textLabel?.textColor = UIColor.red
Thank you. I want to include a map that shows local places(such as restaurants and bars) and be able to change to a list view of those places back from the map. Would you be able to point me in the right direction? I have gotten the google maps api but don't know where to begin to implement this.
Hello,
Start here : https://developers.google.com/maps/
And there are a lot of samples.
Patrick BODET
De : drmikeb [email protected] Répondre à : John-Lluch/SWRevealViewController [email protected] Date : vendredi 8 septembre 2017 à 04:00 À : John-Lluch/SWRevealViewController [email protected] Cc : Courriel BODET [email protected], Mention [email protected] Objet : Re: [John-Lluch/SWRevealViewController] From ViewController navigate back to SWRevealViewController Front Page (#516)
Thank you. I want to include a map that shows local places(such as restaurants and bars) and be able to change to a list view of those places back from the map. Would you be able to point me in the right direction? I have gotten the google maps api but don't know where to begin to implement this.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
How can I use a UIAlert to open the viewcontroller, without using the SWReveal Menu?
You should open a new issue for that as your question is not relative to this one, but is what you need.