MonoTouch: How to Tell If The User Is Selecting Text or Tapping

Goal

Show and hide a toolbar at the bottom of the view when the user taps.

Why

Several apps, particularly those focus on reading the content in the view, offer a UIToolbar (or a custom component with buttons) at the bottom of the view that shows or hides according to the user’s taps.

What we want to detect is a single tap. Not a swipe. Not drag. Not if the user is selecting text.

How

Using a UITapGestureRecognizer we can handle taps on the UIWebView.

I setup a delegate for it and assign a Selector to handle the event.

From there we need to determine if the user is selecting text or just tapping, and show/hide the toolbar.

The Code

 


Categories: iPhoneMonoTouchXamarinPermalink