0

Hey all, I'm completely stumped with this iPhone problem.

This is my first time building a view programmatically, without a nib. I can get the view displaying things just fine, but the darn ViewController isn't responding to touches the way it used to in programs where I used a nib. I should add that in the past, I started with the View-Based Application template, and this time I used the Window-Based Application template.

My thinking is that the View-Based template does something magical to let the iPhone know where to send the touch events, but I can't figure out what that would be even after several hours of bumbling around Google. Or I could be looking in an entirely wrong place and my troubles are related to something else entirely. Any thoughts?

3 Answers3

1

There's nothing magical in the view-based template. The most likely reasons for failure to respond to touches are:

  • You've messed with touchesBegan:withEvent:, userInteractionEnabled, exclusiveTouch or something else, thinking you need to mess with these (generally you don't; the defaults are generally correct)

  • You created a second UIWindow

  • You put something over the view (even if it's transparent)

Simplify your code down to just creating a view programatically that responds to a touch and nothing else. It should be just a few lines of code. If you can't get that working, post the code and we'll look at what's going on.

Rob Napier
  • 286,113
  • 34
  • 456
  • 610
0

Problem solved. touchesEnded != touchedEnded.

That'll teach me to program without my glasses on.

0

Another possible scenario for failure in response to touches is when your VC frame is not predefined and its boundaries are actually exceeding the window placeholder.
It happens a lot when you just forget to define the frame property for the VC.

Once you define it correctly - User interaction returns to normal.

Good luck !

Guys
  • 352
  • 1
  • 3
  • 15