Loading an “overlay” when running long tasks in iOS

前端 未结 11 902
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 16:15

What is example for loading overlay in Swift IOS application when do a long tasks. Example for loading data from remote server. I googled but not found any answer.

U

11条回答
  •  时光说笑
    2020-12-22 16:53

    To add on to the answers given, you might run into issues if you are attempting to run the code sometimes. Personally, there was an occasion where showOverlay was not being properly called (because I was trying to segue into a scene, then immediately call this function during viewDidLoad).

    If you run into an issue similar to mine, there is one fix to the code and a change in approach I recommend.

    FIX: Place both blocks of code as closures to a dispatch_async call, like so:

    dispatch_async(dispatch_get_main_queue(),
     { //code });
    

    APPROACH: When calling your code, do a dispatch_after call onto the main queue to delay the call by a few milliseconds.

    The reasoning? You're simply asking the UI to do too much during viewDidLoad.

    If this appendix to the solution helped, I'd be glad.

    -Joel Long

    P.S. Solution worked for XCode v6.3.2

提交回复
热议问题