AdMob Ads-日志中的主线程检查器错误

时间:2019-07-02 11:41:00

标签: ios swift admob

我刚刚将AdMob添加到了UIViewController中,当我运行该应用程序时,它冻结了几秒钟,然后显示出来:

=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 8093, TID: 1911410, Thread name: com.apple.CoreMotion.MotionThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
Backtrace:
4   libobjc.A.dylib                     0x0000000198a9b894 <redacted> + 56
5   CoreMotion                          0x000000019f321040 CoreMotion + 307264
6   CoreMotion                          0x000000019f321574 CoreMotion + 308596
7   CoreMotion                          0x000000019f321484 CoreMotion + 308356
8   CoreMotion                          0x000000019f352c64 CoreMotion + 511076
9   CoreMotion                          0x000000019f352cc4 CoreMotion + 511172
10  CoreFoundation                      0x00000001998324fc <redacted> + 28
11  CoreFoundation                      0x0000000199831de0 <redacted> + 276
12  CoreFoundation                      0x000000019982d0e4 <redacted> + 2324
13  CoreFoundation                      0x000000019982c4b8 CFRunLoopRunSpecific + 452
14  CoreFoundation                      0x000000019982d21c CFRunLoopRun + 84
15  CoreMotion                          0x000000019f3525fc CoreMotion + 509436
16  libsystem_pthread.dylib             0x00000001994a7974 <redacted> + 132
17  libsystem_pthread.dylib             0x00000001994a78d0 _pthread_start + 52
18  libsystem_pthread.dylib             0x00000001994afddc thread_start + 4

有什么提示吗?

1 个答案:

答案 0 :(得分:0)

  • 您的问题是此过程在Main Thread中。仅UI操作的主线程。否则,UI将冻结。

  • 您应该在后台线程中执行此操作。

    DispatchQueue.global(qos:.background).async {     //您的代码 }

享受。