This application is modifying the autolayout engine from a background thread, which can lead

本文解决了iOS开发中UI线程更新导致的延迟和警告问题,通过将UI更新操作转移至主线程,避免了可能产生的应用程序崩溃风险。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目中遇到一个跳转问题,延时(等待时间)特别久,并且报下面的的提示警告

This application is modifying the autolayout engine from a background thread, which can lead to engine corruption and weird crashes.  This will cause an exception in a future release.

这里写图片描述

问题原因:

问题的原因是因为在子线程中刷新了UI,解决办法是,回到主线程中刷新UI

解决办法:

参考:CocoaChina
   dispatch_async(dispatch_get_main_queue(), ^
            {
                // 更UI

            });
或者
[self performSelectorOnMainThread:<#(nonnull SEL)#> withObject:<#(nullable id)#> waitUntilDone:<#(BOOL)#>]

参见:Stack Overflow

这里写图片描述

其他类似:

(http://blog.youkuaiyun.com/quanqinyang/article/details/49516593)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值