IPhone UIScrollview: The button does not respond if it is positioned below 480 pixels on scrolling. View child UIView

I have created a view for an iPhone application in Interface Builder. This is a UIScrollview with UIView and UIButton to UIView. The only code I have is setting the scrolling in the contentSize to 320x550 in the viewDidLoad method of the xib file owner class. When the button is within its normal viewport (320x480), the button responds as usual, but if it is outside those boundaries in Interface Builder, the button will not respond when I navigate to it and press the button.

What am I missing? I suppose it might be something I need to set in the UIView. But I'm not sure what it is.

+2


source to share


2 answers


Your UIButton will not be responsive even if displayed because it is not on the border of the parent view. You can see the object outside of its parent view because this is the default UIView behavior of drawing the entire subview (clipsToBounds = NO)

To see this, try this code.

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

      



You won't see your UIButton anymore.

To fix this, enlarge your UIView.

+6


source


I had the same problem as the person who posted the question. Thanks to the first answer, I had a hint of what to do. I increased the height of the view by adjusting the border. This apparently needs to be done in code. However, when this was done, the toolbar at the bottom was no longer visible. Therefore, before adjusting the height of the view, I grab the position of the toolbar. Then, after adjusting the height of the image, I reset the position of the toolbar. All is well now.



+2


source







All Articles