New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set content of the menu programmatically #44
Comments
You either need to set the rootViewController in code or in your storyboard. SideMenu itself is just a navigation controller. Please see the demo project for additional insight. |
I did set the rootViewController using SideMenuViewController is my custom view controller. I have to use |
Try doing more testing/debugging to assess root cause; I don't have enough to go on to tell you what's wrong with the info you've provided. Add breakpoints in ViewDidLoad to see if |
After those statement run, debugger shows:
SideMenuViewController never loaded in the first statement. I sub classed UINavigationController just like you do, the topViewController of my sub class is not nil, so I think there is problem with your implementation |
I found the problem: when init with rootViewController, the pushViewControll function is called, you check if menuviewcontroller is nil or not. At init time it always nil. So no code is run. I will submit a PR to fix it if you dont have time, its solved 👍 |
@thang2410199 can you point me to the file/line number? |
I created a PR here #46 I am learning iOS, so it will be really good if I can contribute to your project to learn in the process. |
I appreciate your earnest in wanting to learn contributing to this repo! I came up with a fix for this myself, however I took a different approach. Let's sync on functional expectations of the menu before taking either one. When I used the code snippet you provided at the outset of this issue, and then wire up a button to present the menu programmatically, the menu still appears but without a viewController. From your PR, it seems that you are having problems getting the menu to appear at all because of the missing rootViewController. In UISideMenuNavigationController, I added these lines which successfully set the rootViewController:
|
Wow, I did try your approach first hand, but I think write viewControllers = [rootViewController] is kind of a hack (we are doing the job of super class!). And at the If the menu view controller is created, and navigate to a second Best Regard On Mon, Jul 11, 2016 at 10:39 PM, Jon Kent notifications@github.com wrote:
|
I completely agree it's hacky, but I don't see any other reason why letting the superclass work as normal doesn't work.. I've put breakpoints in all over the code to see where else I might be clearing out the rootViewController and nothing is being called that would seem to indicate a bug. So are you saying your fix demonstrates that you see the rootViewController as expected? |
yes, I do. I debug and see the problem: when init with rootViewController, the framework actually called pushViewController. But your override method did not call super's pushViewController, so in the end there is no view controller added to navigation stack |
Understood! Good find. The reason why pushViewController is overridden is so that if you try to push a viewController from the side menu, it will instead defer that to the main screen. It appears that by overriding it that breaks the Here's how I would write the fix (note that I've learned a bit more about
|
agree, better to read compare to multi level of statements. Btw, you tell me more about the transition (e.g fading) as I interact with the menu (swipe). My way of thinking is that I will observe the offset (?) of the moving controller, and change the alpha of the menu accordingly, I dig into your code and find only |
Actually, one more change. One of those guard statements isn't necessary and was left over from a refactor I did a while back.
Feel free to put this in your PR and I will take it to give you credit for your find/work. Also please remove any excess formatting changes you did outside of this method. Re: parallax, it depends on what you mean. Check out SideMenuManager.menuParallaxStrength to see if that's the effect you were going for (run it on your device, not simulator to see properly). |
Thanks, I will do it tomorrow. About the parallax, its demonstrated in Twitch app (iOS), their left side menu is what I mean by "parallax". the |
I see. The effect you're looking for isn't built into SideMenu currently. You want a modified version of the "In + Out" effect, which would partially slide the menu in as it is revealed. You could build this by either modifying the repo or writing your own subclasses. The trouble with this effect is picking smart defaults, or making them configurable for how much you want the menu to slide as its revealed. I believe the iOS push effect slides the covered screen by either 1/3 or 1/2 of its width. Perhaps this might be a good benchmark for you. |
* tag '1.1.8': Updated pod spec and README for cocoa pods. Fix to prevent side menu from responding to user interaction while being animated in or out. fix #44
Thanks for contributing @thang2410199! |
hi bro, how do actually set rootview controller when tap tableview row |
The code above let me open the side menu, but its empty. It should have root controller = SideMenuViewController(). It never loaded.
I tested SideMenuViewController and it display just fine anywhere else.
The text was updated successfully, but these errors were encountered: