UITextView Scrolling Doesn’t Work

I had an issue where I was unable to get scrolling on a UITextView to work when editing was turned off. I searched and searched through the vast sea of information that is the internet and came up empty.

Basically the problem was that I had nested my UITextView inside of a UIImageView. This seems innocuous enough but UIImageView does not have the userInteractionEnabled flag set to YES by default. Therefore the event was dispatched up to that view from the main thread and was blocked because the view would not handle and propagate the event.

So the solution was to set the UIImageView’s userInteractionEnabled flag to YES.

    self.userInteractionEnabled = YES;

I think there could be other views that are set up like this as well, although I am not sure which ones they would be. So watch out for this, especially if you are defining your views in code.

I hope that this shows up in someone’s Google search and helps them out.

Tags: , , , , ,

CoreData SQLite3 Database Constraint Failed Error

Have you ever seen the following error message:

Error Domain=NSCocoaErrorDomain Code=256 UserInfo=0x3baae90 "Operation could not be completed. (Cocoa error 256.)

Talk about not Helpful.

Inside this there was a userInfo dictionary with the following message:

error during SQL execution : constraint failed

Slightly more helpful, but not by very much.

We came across this error message while we were developing our Electrophobe game. We started the debugging process by inserting logging code and pinpointing where the code was failing out. After about 6 hours of work combing through both code and rebuilt databases we finally found the solution.

The trick was that the primary key store for the SQLite3 database that was backing our CoreData NSPersistenceStore had an incorrect value for the Z_MAX column. This column is used, we believe, to house the maximum primary key in order to quickly retrieve it for additional inserts.

As is evident from our escapade however, it is clearly a little vulnerable to tampering when loading the data directly into the SQLite database. To fix the issue, simply update the table with the max(Z_ID) from the referenced table and it should all hook up again.

Tags: , , , , ,

iPhone 3.0.1 Update Breaks SDK

The title here is a little inflammatory but the solution is quite simple and if we all just read the instructions before installing stuff then maybe we could avoid these problems. But just in case someone else runs across this problem the solution is to run the following command (as indicated by apple in their release notes):

ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \
\(7A341\)/ /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1

This does assume that you are using the default paths.

Tags: ,