views:

383

answers:

1

I have built a view for an iPhone app in Interface Builder. It is a UIScrollview with a UIView and a UIButton on the UIView. The only code I have is setting the scroll view's contentSize to 320x550 in the viewDidLoad method of the xib's File Owner class. When the button is within the normal view area (320x480) the button responds as normal, but if is placed outside of those boundaries in Interface Builder the button will not respond when I scroll to it and click the button.

What am I missing? I figure it might be something I need to set on the UIView. But I am not sure what that is.

+1  A: 

Your UIButton won't response even it's visible because it's not in the boundary of parent view. You can see object outside the boundary of its parent view because it's a default behavior of UIView to draw all subview (clipsToBounds = NO)

To see the truth, try this code.

UIView *yourUIView = ...
yourUIView.clipsToBounds = YES;
yourUIView.backgroundColor = [UIColor cyanColor];

You will no longer see your UIButton.

To fix this, enlarge your UIView.

iwat