3

I am trying to mimic the GLPaint app and I have a TDPaintingView that has methods for -(void)touchesBegan... as well touchesMoved, touchesEnded, and touchesCanceled. However, I am not seeing any of them fire.

I have a TDAppDelegate that is hooked up to a Window in IB and a TDPaintingView in IB. The initWithCoder method for my TDPaintingView definitely fires, so I know it is being initialized. Furthermore, I can see from logging the object TDPaintingView from the context of applicationDidFinishLaunching that it is definitely there. When I change the view in trivial ways in IB (making bg red for example) it is reflected on simulator.

However, my view doesn't receive touches, and it's driving me crazy!

I set a breakpoint on -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event and it never stops, regardless of where I touch on the screen.

My TDPaintingView has no subviews, and it explicitly defines methods for those touches actions.

Where am I going wrong?

tacos_tacos_tacos
  • 10,277
  • 11
  • 73
  • 126
  • Could you show the code relevant to its initialization? Or if you are using IB, then a screenshot of the pane that configures it? Otherwise we will be just guessing – nacho4d Apr 08 '12 at 08:44
  • Did you find a solution? I have two projects, but based on GLPaint. As far as I can see, there are no significant differences between the two projects, however one fires touchesBegan and the other doesn't. The root view receives touches, and could hand it to the paintview, but I like it better that the painting view receives the touches directly. I'll keep digging for an answer.. and share if I find it. – Johan Dec 07 '12 at 14:03
  • I stripped down the project that didn't work, keeping only the essentials. And now it works. So.. There is something that we both did that prevents it from working, not something that needs to be done.. – Johan Dec 07 '12 at 15:19
  • Is your view's [`userInteractionEnabled`](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instp/UIView/userInteractionEnabled) flag set to YES? You can either set it in code, or by checking the "User Interaction Enabled" checkbox in the xib file. – Kurt Revis Apr 08 '12 at 08:15
  • I should have mentioned, in the mainwindow xib file, under the item for the view, User Interaction Enabled is YES and set that way by default in IB I believe... – tacos_tacos_tacos Apr 08 '12 at 08:19
  • @Gatada, I cannot remember anymore, but I've since completely abandoned Interface Builder for anything other than extremely simple views because it creates more problems than it solves. – tacos_tacos_tacos Mar 23 '14 at 11:58

0 Answers0