I have a similar problem described in this thread: Capturing touches on a subview outside the frame of its superview using hitTest:withEvent:
Situation
We are developing an app in Xamarin iOS. We have a custom view to create an own autoComplete input field, containing an UiTextField and an UiTableView beneath to show the results.
To achieve a better modularity we have another custom view called LabeledContainer. Inside it, I can set a label and add content to the bottom view, which is the autoComplete in this case.
AutoComplete LabeledContainer
+---------------+ +---------------+
| UiView | | UiView |
|+-------------+| |+-------------+|
|| UiTextField || || UiLabel ||
|+-------------+| |+-------------+|
|+-------------+| |+-------------+|
|| UiTableView || || UiView ||
|+-------------+| |+-------------+|
+---------------+ +---------------+
The following gets rendered:
MAINVIEW
+------------------------------+
| |
| |
| |
| |
|+----------------------------+|
|| LabeledContainer ||
||+--------------------------+||
||| Label |||
||+--------------------------+||
||+--------------------------+||
||| Content |||
|||+------------------------+|||
|||| AutoComplete ||||
|||+------------------------+|||
||+--------------------------+||
|+----------------------------+|
| |
| |
| |
| |
+------------------------------+
Problem
I have problems with the "hitarea" because the autoComplete dropdown (tableView) is outside of the custom views frame. The frame just takes the height of the input field and the dropdown overlaps it at the bottom. So I added the following method to add the dropdown to the hitArea.
public override bool PointInside(CGPoint point, UIEvent uievent)
{
var bounds = Bounds;
bounds.Height += DROPDOWN.Bounds.Height;
return bounds.Contains(point);
}
But this only works if I add my autoComplete as subChild of the mainView, because PointInside gets triggered there. If I add the autoComplete to the labeledContainer, which has afterwards a frame height of label + inputfield of the autocomplete, the method PointsInside gets never triggered. This is the case because the labeledContainer isn't high enough, right? So PointsInside of a view just gets triggered when the superView gets touched? But I can't make the labeledContainer or autoComplete higher to prevent pushing other views.
I tried to add the PointsInside method also to the labeledContainer, but it didn't solve my problem, because its not touching the labeledContainer frame and the autoComplete PointsInside is never called.