iPhone Dev: UITapRecognizer iOS 5 vs iOS 6

Text Fortress‘ first update (v 1.05) went live yesterday and it fixes a nasty bug where all the buttons in the app seemed to be broken. In the process of fixing this problem, I discovered an interesting difference in the way iOS 5.x and iOS 6.x handles user taps.

First, I’d like to thank Text Fortress user, Vishal Patel, for kindly notifying me of this unintended function. Thanks to him, I was able to pinpoint the problem and fix it easily. Since I primarily tested this app using iOS 6.x, I did not experience the problems Vishal did. It turns out that UITapRecognizer’s property “cancelsTouchesInView” is set to YES by default in iOS 5, but it is set to NO in iOS 6.

This turned out to be a problem in my app because I had it set up to immediately look for taps when the app launched. In iOS 6, this wasn’t a problem, but in iOS 5, it prevented the users from interacting with the UIButtons since the system kept registering it as a tap. There are two ways to fix this problem.

One way is to manually set UITapRecognizer’s “cancelsTouchesInView” to NO. Another way, which is what I opted to do, was to check for taps only when necessary. For example, I was using the tap gesture to dismiss the on-screen keyboard. Instead of looking for taps right from the get go, I simply started looking for taps when the keyboard was present (the keyboard covered the buttons anyway). So there you have it, a little food for thought for beginner iOS devs.

Advertisements

One thought on “iPhone Dev: UITapRecognizer iOS 5 vs iOS 6

  1. Hello blogger, i must say you have high quality articles
    here. Your blog should go viral. You need initial traffic only.
    How to get it? Search for; Mertiso’s tips go viral

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s