gpt4 book ai didi

iOS 乱舞 : UI API called from background thread

转载 作者:行者123 更新时间:2023-12-02 03:07:56 24 4
gpt4 key购买 nike

使用 xcode 9.3 beta 实现 flurry 会导致有关后台线程调用的 UI API 的警告。必须仅从主线程调用。

知道如何避免这种情况 - 是否只能通过 flurry 来解决?

应用程序委托(delegate)中使用的代码:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

let builder = FlurrySessionBuilder.init()
.withAppVersion("1.0")
.withLogLevel(FlurryLogLevelAll)
.withCrashReporting(true)
.withSessionContinueSeconds(10)

// Replace YOUR_API_KEY with the api key in the downloaded package
Flurry.startSession("YOUR_API_KEY", with: builder)
return true
}

最佳答案

试试这个:

objective-c

dispatch_async(dispatch_get_main_queue(), ^{
// add UI related changes here
});

swift

DispatchQueue.main.async {
// add UI related changes here
}

关于iOS 乱舞 : UI API called from background thread,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45183278/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com