iOS 14 YYAnimatedImageView加载图片失败处理

升级到iOS14,之前使用的YYimage框架全部不能正常显示图片,当然动态图正常显示,静态图无法显示;

原因是:14.0 系统调用了下面方法,YYAnimatedImageView没有正确处理

-(void)displayLayer:(CALayer )layer;

1

可以用以下方式处理:

方式一:

更改YYimage源码,在YYAnimationImageView.m中

  • (void)displayLayer:(CALayer *)layer {

if (_curFrame) {

layer.contents = (__bridge id)_curFrame.CGImage;

} else {

if (@available(iOS 14.0, *)) {

super displayLayer:layer\]; } } } 方式二: 不更改YYimage源码,以防之后作者升级,使用Hook的技术处理 + (void)load { Method a = class_getInstanceMethod(self, @selector(displayLayer:)); Method b = class_getInstanceMethod(self, @selector(swizzing_displayLayer:)); method_exchangeImplementations(a, b); } - (void)swizzing_displayLayer:(CALayer \*)layer { //通过变量名称获取类中的实例成员变量 Ivar ivar = class_getInstanceVariable(self.class, "_curFrame"); UIImage \*_curFrame = object_getIvar(self, ivar); if (_curFrame) { layer.contents = (__bridge id)_curFrame.CGImage; } else { if (@available(iOS 14.0, \*)) { \[super displayLayer:layer\]; } } }

相关推荐
2501_9159090611 小时前
手机崩溃日志导出的工程化体系,从系统级诊断到应用行为分析的多工具协同方法
android·ios·智能手机·小程序·uni-app·iphone·webview
无意feel13 小时前
MacOS 安装neofetch cmatrix lolcat
macos·数字雨·彩虹特效
KevinShi_BJ14 小时前
MacOS 上安装 Docker 和启动 LangBot
macos
2501_9151063215 小时前
App HTTPS 抓包实战解析,从代理调试到真实网络流量观察的完整抓包思路
网络协议·http·ios·小程序·https·uni-app·iphone
ricky_fan16 小时前
(25年12月)claude code报错:might not be available in your country
macos·bash
要站在顶端16 小时前
iOS自动化测试全流程教程(基于WebDriverAgent+go-ios)
开发语言·ios·golang
2501_9160088916 小时前
深入理解 iPhone 文件管理,从沙盒结构到开发调试的多工具协同实践
android·ios·小程序·https·uni-app·iphone·webview
james bid16 小时前
MacBook Pro 2015 上 XUbuntu 24.04 启用 eGPU (GeForce GTX 1080 Ti) 和核显黑屏问题解决
linux·ubuntu·macos·cuda·egpu
私人珍藏库17 小时前
[Mac] Mac风扇控制软件 iFan V1.1.1
macos
腾讯云qcloud075518 小时前
腾讯位置商业授权iOS 轨迹SDK
macos·ios·cocoa