iPhone Dev: UIScrollView Unresponsive – Interface Builder Bug?

Hello, hello! I haven’t written in a while and that’s mostly because I’ve been knee deep in my newest app, Pxture, which is finally available in the Apple App Store for the very inexpensive price of FREE.

While I was building the app, I encountered a possible bug. I was trying to get two UITableViews horizontally adjacent to each other in a single UIScrollView so I could essentially swipe left and right to switch table views.

I used interface builder to accomplish this but encountered a bug along the way. I placed the UIScrollView inside a UIView. I then placed the two UITableViews inside the UIScrollView.

I ran the app, and I was able to swipe left and right on the UIScrollView and see the UITableViews inside whiz by. I was also able to swipe up and down to scroll through the UITableView cells. Everything was working so nicely!

However, after I return to the root view from clicking into a UITableView cell to view the detail page, the UIScrollView would cease to respond! I could, however still interact with the UITableView. It made no sense at all! It’s as if the scroll view was non-existent. I NSLogged some touch points and found that views inside the scroll view returned nothing.

After searching the internet, it seems that this is a common problem and is a possible bug in IB. I eventually unchecked “Use Autolayout” on my IB file and viola! Everything was working once again. I always had a bad feeling of this auto layout crap that Apple is trying to push on us. It’s more of a headache than it’s worth!

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.