1. 程式人生 > >iOS 11出現的坑,Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrien

iOS 11出現的坑,Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrien

2017-11-13 11:39:04.348973+0800 PlantsAndFlowers[11262:2146383] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation]

PID: 11262, TID: 2146383, Thread name: (none), Queue name: BaseOperatorService, QoS: 0

Backtrace:

4  PlantsAndFlowers                    0x0000000100bb4c0c __25-[MOBFBaseService _putAd]_block_invoke + 536

5  libdispatch.dylib                  0x000000010104149c _dispatch_call_block_and_release + 24

6  libdispatch.dylib                  0x000000010104145c _dispatch_client_callout + 16

7  libdispatch.dylib                  0x0000000101050110 _dispatch_queue_serial_drain + 692

8  libdispatch.dylib                  0x00000001010449a4 _dispatch_queue_invoke + 332

9  libdispatch.dylib                  0x0000000101051104 _dispatch_root_queue_drain_deferred_wlh + 424

10  libdispatch.dylib                  0x0000000101058100 _dispatch_workloop_worker_thread + 652

11  libsystem_pthread.dylib            0x0000000182adefd0 _pthread_wqthread + 932

12  libsystem_pthread.dylib            0x0000000182adec20 start_wqthread + 4

造成原因是因為原本 需要在主執行緒執行的程式碼 被放在了子執行緒裡邊

解決方法:在scheme 裡邊取消主執行緒檢測 (如下圖   不建議使用) 或者修改程式碼 把出問題的程式碼放在主執行緒裡邊即可