升级到XCode 9后,我在运行应用程序时突然收到以下警告:
Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState] PID: 15473,TID: 773864,Thread name: com.google.Maps.LabelingBehavior,Queue name: com.apple.root.default-qos.overcommit,QoS: 21 Backtrace: 4 App 0x000000010b8ee524 GMSIsApplicationInBackground + 53 5 App 0x000000010b8dc77a -[GMSForegroundDispatchQueue initWithName:targetQueue:] + 269 6 App 0x000000010b9bc5ee _ZN7gmscore6vector4text8GlyphSetC2ERKNS_4base10reffed_ptrINS0_16TextureAtlasPoolEEEPU28objcproto17OS_dispatch_queue8NSObjectPK8__CTFontff + 344 7 App 0x000000010b9bba58 _ZN7gmscore6vector4text10GlyphCache11GetGlyphSetEPK8__CTFontf + 214 8 App 0x000000010b9b950e _ZN7gmscore6vector4text6GLText14PrefetchGlyphsERKNS_4base10reffed_ptrINS1_10GlyphCacheEEERKNSt3__16vectorItNS9_9allocatorItEEEEPK8__CTFontf + 22 9 App 0x000000010b9b9611 _ZN7gmscore6vector4text6GLText14PrefetchGlyphsERKNS_4base10reffed_ptrINS1_10GlyphCacheEEEPK8__CTLinebf + 207 10 App 0x000000010b9112df _ZN7gmscore6vector12GLPointLabel22PrefetchGlyphsForGroupEPNS0_12GLLabelGroupE + 181 11 App 0x000000010b911207 _ZN7gmscore6vector12GLPointLabel14PrefetchGlyphsEv + 33 12 App 0x000000010b98022a _ZN7gmscore6vector16LabelingBehavior23CreatePendingOperationsERKNSt3__13setINS_4base10reffed_ptrINS0_7GLLabelEEENS2_4lessIS7_EENS2_9allocatorIS7_EEEESE_SE_NS0_13LabelDrawModeE + 1096 13 App 0x000000010b97fb9d _ZN7gmscore6vector16LabelingBehavior14RunLabelingJobERKNS_4base10reffed_ptrINS1_11LabelingJobEEE + 357 14 App 0x000000010b97fa2a ___ZN7gmscore6vector16LabelingBehavior14CommitInternalEPNS_8renderer14EntityRendererE_block_invoke + 22 15 Foundation 0x0000000110bb0948 __NSThreadPerformPerform + 334 16 CoreFoundation 0x00000001117af2b1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 17 CoreFoundation 0x000000011184ed31 __CFRunLoopDoSource0 + 81 18 CoreFoundation 0x0000000111793c19 __CFRunLoopDoSources0 + 185 19 CoreFoundation 0x00000001117931ff __CFRunLoopRun + 1279 20 CoreFoundation 0x0000000111792a89 CFRunLoopRunSpecific + 409 21 Foundation 0x0000000110b6ae5e -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 274 22 App 0x000000010b9bace5 -[GMSx_GTMSimpleWorkerThread main] + 337 23 Foundation 0x0000000110b788ac __NSThread__start__ + 1197 24 libsystem_pthread.dylib 0x000000011323393b _pthread_body + 180 25 libsystem_pthread.dylib 0x0000000113233887 _pthread_body + 0 26 libsystem_pthread.dylib 0x000000011323308d thread_start + 13 Error Domain=kCLErrorDomain Code=0 "(null)"
当我将地图分配给我的视图时,我可以将其缩小到问题.
override func viewDidLoad() { super.viewDidLoad() UIApplication.shared.isIdleTimerDisabled = true GPSManager.instance.startGPS() setupLayout() map = GMSMapView.map(withFrame: CGRect.zero,camera: getCamera(location: initialLocation,zoom: 10)) map.mapType = .hybrid map.delegate = self map.settings.consumesGesturesInView = false self.view.addSubview(map) <-- This is where is goes wrong self.view.sendSubview(toBack: map) configureMenus() }
这是我可以解决的问题还是在Google地图中?干杯