appFormation
appFormation

Reputation: 253

UIButtons located in a UIView underneath interfering

I have a UIScrollView over the main view of the view controller. UIScrollView contains some UIButtons (detail disclosure type) and a floating UIView -- all managed by only one view controller.

The floating UIView also contains its own UIButtons (custom, not rounded type). User is allowed to hide the floating UIView, or move it to a new location.

I found that the UIButtons contained in the UIScrollView (parent) are interfering with (preventing) tapping of the UIButtons contained in the floating UIView whenever these UIButtons overlap. If partially overlapped, only the overlapped area is a dead zone. I tried explicitly bringing the floating UIView to the front by issuing this message:

[self.myScrollView bringSubviewToFront:myFloatingView];

-but the problem does not go away.

The interference goes away if I keep the UIButtons of the parent hidden. But, this is not what I want.

Any suggestion will be appreciated.

Thanks you

Upvotes: 0

Views: 194

Answers (1)

Robert
Robert

Reputation: 38213

A button can not interfere in the way you described. I think it something else.

All of the times I have had similar issue have been because subviews were taken outside the bounds of their parent views. The rule is:

If a subview is outside of its parent view's bounds it will not receive touch events.

This isnt explicitly stated in the docs but you can infer it by reading sections of the touch event guide.

I think what might be happening is that you are moving the floating UIView outside of its parent bounds.

It might not be it, its just a suggestion.

Upvotes: 1

Related Questions