Search code examples
iosswiftuiwindow

Disabling user interaction in entire screen


I have a main controller and adding picker view when user selects SORT. I want to disable complete user interaction except Picker Control (Cancel and Done Button). I am adding picker as subview to window.

I tried using following before and after animation but it disables everything including Picker Controls.

UIApplication.shared.beginIgnoringInteractionEvents()
UIApplication.shared.endIgnoringInteractionEvents()

Is there any other solution to disable user interaction app wide?

enter image description here


Solution

  • Since the picker is added to window's view , you can do this in the currentVC

    self.view.isUserInteractionEnabled =  // true/false
    

    also as you have a navigation , you may also do

    self.navigationController?.navigationBar.isUserInteractionEnabled =  // true/false