Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Implementing simple touch recognizer on UIWebView to hide nav bar and toolbar

Hi,

Can anyone point me in the right direction of how I can implement a simple recognizer that when you tap on a uiwebview it makes the screen go full screen and hides a nav bar and a toolbar at the bottom and then when you tap it brings them back. It's pretty much how safari works, but somehow I can't figure this out.

Thanks.

2 Answers

Gareth,

Have you looked at the Apple docs for UIGestureRecognizer, specifically UITapGestureRecognizer? This will explain how to implement a tap gesture. In the implementation of the tap gusture method you can then hide/unhide the nav bar and tool bar.

UIGestureRecognizer Class Reference

Hi Dennis,

I tried everything I could think of with that thing. It seems there are some quirks when using it with a UIWebView that I don't understand. I was able to get it to work on a scroll view with some text on it, but not on the UIWebView. I googled for a few hours and some people had some super complicated work arounds for it, but I couldn't get any of them to work. I could be doing something wrong, but a lot of people were saying that the UIGestureRecognizer doesn't work well with UIWebView.

Thanks.