I'm working on an app that includes the screen shown below. The panel with the list view is instantiated from a Nib, but the pale grey panel with the drawing in it is a dynamically generated UIView, which is a subview of a UIView subclass called FrameView (for the purposes of the question).
The red dot in the corner is a delete button for that drawing. The drawing is the content of a Drawing Object, which has a many-to-many relationship to the item selected in the list. When I select an item in the list, zero or more such panels, showing the drawings for that item are added as subviews of FrameView.
In order for those delete buttons to be clickable, FrameView has user interaction enabled. This happens when I select an item in the list. It's off when FrameView first appears.
At the bottom left is the key navigation button. it has a variety of gestures and clicks associated with it, that allow the user to move between different editors, that use the main screen. This button has a relatively high zPosition, in the main view.
But once FrameView has its user interaction turned on, it stops clicks and gestures from reaching the navigation button.
I would have thought that increasing the zPosition of the navigation button above FrameView would solve the problem, but it doesn't. How can I make the navigation button receive taps and gestures, even when FrameView has user interaction enabled? Or am I going about this the wrong way?
EDIT: meant to mention the navigation button is the only element added via Storyboard, in case that matters
EDIT 2: After some messing around, I'm overriding the hitTest, so:
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? {
let view = super.hitTest(point, with: event)
return view == self ? nil : view
}
This wasn't sourced from SO, and although there were some answers here that vaguely suggested this approach, they were (as is common on SO) a) associated with obsolete versions of Swift, b) buried in a different context and c) not returned by any obvious searches.
This site has got to do something about obsolete, heavily upvoted answers. I think that Swift has got to be the worst case for this, since there really are so few users of the older versions, thanks to Apple's forced-upgrade policies.
Thanks to Ptit Xav for sticking your head into my mess.