iDevelopper / PBRevealViewController

A UIViewController subclass for revealing a left and/or right view controller above or below a main view controller.
MIT License
80 stars 16 forks source link

Using this library with segues #55

Closed sashberd closed 6 years ago

sashberd commented 6 years ago

Hi

I have an application with segue navigation between VC. I have to add left side menu button and decide to do it with your great lib.

I added nav bars and connect them to my left side and main controllers

I have 2 problems with it:

1) on each prepare for segue I used next function:

 func changeMainController(_ viewController: UIViewControllerl) {        
         revealPBViewController()?.pushMainViewController(viewController, animated:true)
}

But if I try to use simple back button with dismiss action nothing happens. It looks like the method above does not save VC hierarchy and that is why nothing to dismiss

Is there is an option to use this lib with segues or only with instantiated VC`s like in your swift example?

2) My left side menu is empty and I have no idea why(may be I miss something in set up) img_0044

Here is my simple application storyboard screen shot 2018-10-24 at 16 51 16

iDevelopper commented 6 years ago

Not sure to understand all.

PBRevealViewController does not manage a stack of view controllers as UINavigationController, but a left, main and right view controllers.

If I understand, you would like to push a view controller (embed in a navigation controller) and when pushed, have a back button to come back ? For that, you should push with PBRevealViewController the navigation controller of the main view controller. Before pushMainViewController (or in your prepareForSegue implementation) you have to hide the side view controller (animated = false).

You can find how to in the first example of the repo (example for PBRevealViewController), in RightMenuTableViewController.m, didSelectRowAtIndexPath when indexPath.row = 3 (I know, I should rewrite my examples, the first of them, to make them clearer).

Otherwise, I don't know why you menu is empty, perhaps the class of your controller is not well set in the storyboard. I hope you can upload here an sample project so that I can help you!

Thanks!

sashberd commented 6 years ago

@iDevelopper Thanks for help

I tried to ask you that in all your examples you used manual view instantiation with: instantiateViewController function and you do not use segues

May be with segues there is a problem with implementation because I have tried to push my navigation controller of my view controller, but it is nil 😞 I used next change in function:

func changeMainView(_ viewController: UIViewController, isMenuHidden isGestureDisabled: Bool) {
        if let navController = viewController.navigationController {
            revealPBViewController()?.pushMainViewController(navController, animated: true)
        }

screen shot 2018-10-25 at 9 51 05

Just to information - in origin I did not had any navigation controllers in my application. This change is new one. It will be little complicated to upload my project, but I will create a new one and will try to simulate a problem

If you still cannot help me with this issue please do not close it, I will try to upload some simulation ASAP

iDevelopper commented 6 years ago

Example2 use segues (identifiers: LeftToMain and RightToMain).

Example for PBRevealViewController, the first example, push the view controller with the main navigation controller (RightMenuTableViewController.m, didSelectRowAtIndexPath when indexPath.row = 3)

In your case you cannot use segue because you don't want a new instance of main view controller. You want to use the navigation controller of the main view controller to push another controller.

"When the storyboard runtime detects a custom segue, it creates a new instance of your class, configures it with the view controller objects, asks the view controller source to prepare for the segue, and then performs the segue."

iDevelopper commented 6 years ago

This is a sample:

PBRevealIssue55Sample.zip

iDevelopper commented 6 years ago

Did you solve your issue?

sashberd commented 6 years ago

@iDevelopper Hi

Yes, I just hire freelancer that fixed all my issues with segue. The problem was in Main.storyboard itself and in my realisation of project segues at all Thanks for you help Great lib man!!!

iDevelopper commented 6 years ago

Glad to hear it! Thanks!