非主线程上的 SKStoreProductViewController 初始化 [英] SKStoreProductViewController initialization on non main thread

查看:26
本文介绍了非主线程上的 SKStoreProductViewController 初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在非主线程上初始化 SKStoreProductViewController 时偶尔会出现崩溃.我没有看到任何关于在主线程上初始化它的文档.SKStoreProductViewController 需要在主线程初始化吗?

I am seeing an occasional crash as I initialize SKStoreProductViewController on non main thread. I don't see any docs about initializing it on main thread. Do we have to initialize SKStoreProductViewController on main thread?

推荐答案

我只是把这个作为一个答案,以便它可以突出 rmaddy 在评论中提出的观点.

I just made this as an answer so that it can highlight the point made by rmaddy in the comment.

重要

仅在应用的主线程或主调度中使用 UIKit 类队列,除非另有说明.这个限制特别适用于派生自 UIResponder 或涉及的类以任何方式操纵应用的用户界面.

Use UIKit classes only from your app’s main thread or main dispatch queue, unless otherwise indicated. This restriction particularly applies to classes derived from UIResponder or that involve manipulating your app’s user interface in any way.

https://developer.apple.com/documentation/uikit

正如 rmaddy 指出的,类定义:

And as rmaddy pointed out, the class definition:

open class SKStoreProductViewController : UIViewController

所以是的,你需要使用主线程.

So yes, you need to use the main thread.

这篇关于非主线程上的 SKStoreProductViewController 初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆