TimOliver/TOWebViewController

Preserve Application Buttons (e.g. Left Menu hamburger button)

sergii-frost opened this issue · 4 comments

Hi,
I have found your pod quite easy to use, but I am facing some issues when it comes to using it within app which is based on Left Menu navigation (e.g. https://github.com/gotosleep/JASidePanels )

The case is that I want to use TOWebViewcontroller wrapped in UINavigationController and still show Menu hamburger button as the leftBarButtonItem so that user could open menu still.

I have tried adding my hamburger button to the applicationBarButtonItems but then it goes to the toolbar.

Hi Sergii!

Thanks a lot! I'm glad you found my library useful!

Oh dear! That's an interesting set of requirements. Unfortunately, I don't think that's possible with TOWebViewController's current setup. It heavily manages both the toolbar buttons and the navigation buttons, for its UINavigationItem since it needs to be able to reconfigure their layout depending on what sort of size classes the view is adopting (e.g., split screen on an iPad Air 2 etc).

I originally added applicationBarButtonItems so I could optionally add a 1Password button, so its mainly for bar buttons that would go along with the main navigation buttons; there's no way to explicitly force it to stay in the top left corner of the navigation bar.

The only way I think this would be possible is if you added another property to the web view controller to explicitly manage a bar button item for this purpose. You'd need to then modify the code that handles laying out the navigation buttons/application buttons to also account for that extra button.

Sadly, I don't have time to do that, but if you want to try doing it, I'll gladly accept all pull requests! :)

Hi Tim!
Thank you for your quick response and welcoming me!

I have actually solved my issue, The solution is not as elegant as it could be, but it works and I have tested it on both iPad and iPhone, with cases when TOWebViewController is wrapped with empty UINavigationBarController or pushed to the existing one.

You can take a look at my solution in this PR: #80

I have eventually found some quite minor issue (got it when did not do proper setting of .url property in the TOWebViewController instance - app crashed in case if I tapped on Action button due to nil property which was used in an array.

Feel free to comment on any of my changes and I will improve them. As still this is pretty specific to my app, but may be useful for anyone else using left side menu as I am doing.

Hi Sergil! Thanks for your PR! I've just finished making some modifications to your PR and pushed out a new CocoaPods release including it. I figured it'd be easier if users explicitly provided an array of UIBarButtonItem objects that will always remain in the top left hand corner. This makes things a bit more easier to understand from the outside.

Oh cool! Thanks for the bug fix as well then! :)

Hi Tim, thanks for merging it and making it public :)