Question

My problem is the button are shown but irresponsive. Even the textfields. In the image below, textfield 1 and 2 and buttons 1 and 2 do not get touch event. But other textfields above got touches. The problem occurs when tapping on a text field shows the keyboard. But before keyboard appears, all the textfield were active and buttons were responsive.

The UI hierarchy is,

UIScrollView (cyan)
|---UIView (blue)
    |---  All other views (text field, buttons) 

At first cyan and blue views are of equal size. All the textfields and button views are drawn in the UIView. So when keyboard appears I resize the views. Though earlier UIView and UIScrollview have the same area, after keyboard shown, the blue UIView becomes smaller, but its subViews (button, text fields) is outside its area. They are shown, but receive no touch events.

The size of blue view (UIView) is not much important to me. I need at least that the buttons and text field get the touch events. If I disable autoresizing for UIView (blue view) then it solves the problem.

My confusion is the components are shown but why not responding to events?

enter image description here

Was it helpful?

Solution

Your problem is the blue view. If a subview is bigger than it's superview, the other parts (which are not on the superview) of the subview does not respond to touch events. You should improve your resizing, when the keyboard appears.

OTHER TIPS

The superview frame is a depending factor in achieving the touch event.You must make the superview frame the correct way ,in your case the blue view. Inside the superview frame the touch events can be proper.

setup clip subview property to yes of the blue view and then you can see what all comes inside the view frame

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top