views:

54

answers:

2

Hi, I’m an experienced developer, but relatively new to iOS.

I’m having some trouble with an iPad App, where my views are not responding to button touches in the bottom third of the screen. Touches on other buttons are working fine, so I know my views are getting hooked up properly when they’re loaded (I’ve created them in IB.) I get the same behavior on both the simulator and the device.

This is a landscape-orientation-only App, and I’m loading views using [NSBundle LoadNibNamed:]. This was the only non-trivial portion of the App, and I think I’ve jumped through all the appropriate hoops:

  • Added Initial Interface Orientation line to my .plist
  • Designed my views in Landscape orientation in IB
  • Added shouldAutoRotateToInterfaceOrientation to my top-level view that only return YES for landscape orientations

The landscape orientation may not be related, but I thought I should mention it, since it was the only thing I found a little wonky to build, and I see from the boards that other people have found this problematic as well..

Does anyone have any ideas?

Thanks.

A: 

More than likely, your autoresizing masks are not set correctly. This means that the view's bounds are not changing to match the window. Touches are only detected within the bounds of a view's super view, so if you have a button that sits outside its superview's bounds, it won't get any touches.

For a quick test, try setting your view's background color and see if the view does properly extend to the bottom of the screen.

David Liu
The view (and its containing view) are both the full size of the screen. The view also contains an image that's the full size, and the entire image is displaying properly. Also, I can see the buttons, so doesn't that mean they're within the view's bounds?
AndrewCr
No, it doesn't. The default value for UIView clipsToBounds property is set to NO, which allows any subview to display itself outside the view's bounds. That's why the background color test is useful: It allows you to see visually where the bounds of a view actually are on screen.
David Liu
A: 

It turns out my view's bounds were set to the full screen, but the frame was not. By explicitly setting the frame, I was able to get this working.

AndrewCr

related questions