Search code examples
iosxcode4

UITapGestureRecognizer from Objects library in storyboard on a view which is inside a tab bar controller


I added a UITapGestureRecognizer to a view which is inside a tab bar controller and when I switch to the tab which contains the view with the UITapGestureRecognizer, I get a crash with the message -

-[__NSCFString setView:]: unrecognized selector sent to instance 0x2ae8d0

I am using Xcode 4.3


Solution

  • i had this same trouble on iOS5 only with an app targeted to iOS 5 and iOS 6 and a gesture recognizer on the last tab. our code also has very similar gesture-recognizers that are loaded for modal dialogs or pushed view controllers for other tabs. so it was only gesture-recognizers in a tab that was not the first tab, and only in the rootViewController for that tab.

    as Arunabh Das ended up doing, it would seem the only answer is really to add the UIGestureRecognizers in code. there is a thread at Ray Wenderlich's website (which is a decent site containing some good iOS tips) , which, summarized, notes that there appears to be a bug in iOS5, starting with the beta versions, never fixed in the final, and containing a code-snippet that shows how to put the gesture-recognizers in code if you want them.