I have a UIView in a UIScrollView in a UIView in a .xib that contains several buttons. If I move that UIView down by several pixels from within viewWillAppear
, the buttons all stop responding to taps.
Here's the code I'm using to resize the UIScrollView and shift the buttons down:
// adjust the view height to accomodate the resized label
scrollView.contentSize = CGSizeMake( 320, 367 + expectedLabelSize.height - originalLabelSize.height );
// Adjust the location of buttons
CGRect buttonsBounds = buttons.bounds;
buttonsBounds.origin.y -= expectedLabelSize.height - originalLabelSize.height; //XX
buttons.bounds = buttonsBounds;
If I comment out the line marked XX, the buttons work just fine, but are in the wrong place of course.
If I try various numbers of pixels (replacing expectedLabelSize.height - originalLabelSize.height
with a hardcoded value), I get interesting results. 10 pixels works fine. 50 pixels causes my top button to work fine but my bottom one to fail. 100 pixels and both buttons fail. (-50) pixels causes the bottom button to work fine but the top to fail.
Any idea what might be causing the problem? Do I somehow need to inform the buttons that their parent view has moved?