1

I have a map and some buttons inside main UIViewController and a popup view inside child UIViewController. The problem is that main view of child UIViewController preventing main buttons and map from receiving any touch event!

the structure as following:

  • Main UIViewController
    • view
      • MapView
      • UIButton
  • Child UIViewController
    • view . <-- this prevents main view controllers from receiving any touch events
      • popup UIView
      • buttons

Edit:
this code pass all events but I don't need to stop popup UIView and buttons events

override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
print("Passing all touches to the next view (if any), in the view stack.")
return false

}

Dot Freelancer
  • 4,083
  • 3
  • 28
  • 50
  • 1
    https://stackoverflow.com/questions/3834301/ios-forward-all-touches-through-a-view – Bence Pattogato Sep 12 '18 at 11:17
  • @BencePattogato when I do that, mapview annotations stop receiving any touch events – Dot Freelancer Sep 12 '18 at 11:22
  • 1
    I think, you gives your control to the childVC which prevents your mainVC. – dahiya_boy Sep 12 '18 at 11:23
  • Are you saying that this "popup view" is covering up tappable buttons on the main view? Seems to me that a UI issue, not an event issue. I can think of three options in this case. (1) Make your "popup" view movable, even though that not usually seen in iOS apps. (2) Make your "popup" closable and let the user decide on what to tap. (3) Make your "popup" static/fixed and don't hide things underneath it. Now... if your issue is events happening in the "popup" are not getting seen by the underlying VC, make the underlying VC a delegate of the popup. –  Sep 12 '18 at 11:30
  • I just updated the question to clarify current situation – Dot Freelancer Sep 12 '18 at 11:36

1 Answers1

0

based on @BencePattogato answer, this code fixed my issue. thanks

class UnTouchableView: UIView {
    override func point(inside point: CGPoint, with event: UIEvent?) -> Bool {
        return subviews.contains(where: {
            !$0.isHidden && $0.point(inside: self.convert(point, to: $0), with: event)
        })
    }
}
Dot Freelancer
  • 4,083
  • 3
  • 28
  • 50