Adding & Removing A View Overlay in Swift

前端 未结 1 1774
别那么骄傲
别那么骄傲 2020-12-30 15:55

Following from this question: Loading Screen from any Class in Swift

Issue: The loading overlay view will display but will not hide when hideOverlay

相关标签:
1条回答
  • 2020-12-30 16:46

    Swift 2

    Are you calling hideOverlayView() from a background thread? If you are, you should make sure it runs on the main thread:

    dispatch_async(dispatch_get_main_queue(), { // This makes the code run on the main thread
      LoadingOverlay.shared.hideOverlayView()          
    })
    

    Swift 3+

    DispatchQueue.main.async {
      LoadingOverlay.shared.hideOverlayView()
    }
    
    0 讨论(0)
提交回复
热议问题