2

How would I disable a user from interacting with any elements in the view controller while downloading data for that view?

onStartParse()
fetchUserInfo()
onFinishedParse()

I have these 3 methods in my viewDidLoad. The fetchUserInfo() is the method which actually does the downloading from my database

6
  • 2
    controller.view.userInteractionEnabled = false Commented Apr 25, 2016 at 17:16
  • 2
    Possible duplicate of Disabling user interaction of the current view on screen Commented Apr 25, 2016 at 17:16
  • You can set userInteractionEnabled to false when you stat downloading. When the download ends, set userInteractionEnabled back to true. Look at the linked duplicate if you would like to disable interaction temporarily in the entire app. Commented Apr 25, 2016 at 17:17
  • 1
    Possible duplicate of Disable User Interaction with a ViewController temporarily Commented Apr 25, 2016 at 17:18
  • buttons are still able to be pressed during download Commented Apr 25, 2016 at 18:31

1 Answer 1

8

Write the below function on start downloading and on complete downloading in swift

func onStartDownloading(){
self.view.userInteractionEnabled = false

}

func onCompleteDownloading(){

self.view.userInteractionEnabled = true
}
Sign up to request clarification or add additional context in comments.

3 Comments

I tried this but buttons are still pressable and bring about their respective actions
Do you have buttons on navigation bar or at TabBar , it is possible if the button are the part of superview?
None of the UIElements are being disabled, whether on the view or in the navigation bar

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.