iOS Showing All Messages Assertion failed: (aliasSectionNum == sectionNum && "al

复制代码
本人亲测有效!更多交流可以家魏鑫:lixiaowu1129,公重好:iOS过审汇总,一起探讨iOS技术!

问题一:

Xcode运行旧版本项目编译报以下错误:

ini 复制代码
Showing All Messages Assertion failed: (aliasSectionNum == sectionNum && "alias and its target must be located in the same section"), function assignAliasAtomOffsetInSection, file Layout.cpp, line 3248.
解决办法:Build Settings -> Other Linker Flags 中添加 -ld64

问题二:UIGraphicsBeginImageContextWithOptions 方法崩溃(Crash)

objectivec 复制代码
*** Assertion failure in void _UIGraphicsBeginImageContextWithOptions(CGSize, BOOL, CGFloat, BOOL)(), UIGraphics.m:410
解决办法:将下面代码替换
swift 复制代码
UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, self.contentsScale);CGContextRef context = UIGraphicsGetCurrentContext();if (self.opaque) {CGSize size = self.bounds.size;size.width *= self.contentsScale;size.height *= self.contentsScale;CGContextSaveGState(context); {if (!self.backgroundColor || CGColorGetAlpha(self.backgroundColor) < 1) {CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);CGContextAddRect(context, CGRectMake(0, 0, size.width, size.height));CGContextFillPath(context);}if (self.backgroundColor) {CGContextSetFillColorWithColor(context, self.backgroundColor);CGContextAddRect(context, CGRectMake(0, 0, size.width, size.height));CGContextFillPath(context);}} CGContextRestoreGState(context);}task.display(context, self.bounds.size, ^{return NO;});UIImage *image = UIGraphicsGetImageFromCurrentImageContext();UIGraphicsEndImageContext();self.contents = (__bridge id)(image.CGImage);
替换为:
swift 复制代码
UIGraphicsImageRendererFormat *format = [[UIGraphicsImageRendererFormat alloc] init];format.opaque = self.opaque;format.scale = self.contentsScale;UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:self.bounds.size format:format];UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {CGContextRef context = rendererContext.CGContext;if (self.opaque) {CGSize size = self.bounds.size;size.width *= self.contentsScale;size.height *= self.contentsScale;CGContextSaveGState(context); {if (!self.backgroundColor || CGColorGetAlpha(self.backgroundColor) < 1) {CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);CGContextAddRect(context, CGRectMake(0, 0, size.width, size.height));CGContextFillPath(context);}if (self.backgroundColor) {CGContextSetFillColorWithColor(context, self.backgroundColor);CGContextAddRect(context, CGRectMake(0, 0, size.width, size.height));CGContextFillPath(context);}} CGContextRestoreGState(context);}task.display(context, self.bounds.size, ^{return NO;});}];self.contents = (__bridge id)(image.CGImage);
相关推荐
马拉萨的春天2 小时前
iOS中广告SDK如何判断一个广告是否真实展示
macos·ios·cocoa
ajassi20002 小时前
开源 Objective-C IOS 应用开发(十九)视频的播放
ios·开源·objective-c
2501_915918412 小时前
苹果上架 iOS 应用的工程实践,一次从零到上线的完整记录
android·ios·小程序·https·uni-app·iphone·webview
ajassi20003 小时前
开源 Objective-C IOS 应用开发(二十二)自定义控件--车速仪表盘
ios·开源·objective-c
從南走到北4 小时前
JAVA国际版同城跑腿源码快递代取帮买帮送同城服务源码支持Android+IOS+H5
android·java·ios·微信小程序
X***48964 小时前
JavaWebSocket案例
ios·finebi·view design
2501_915918414 小时前
如何解析iOS崩溃日志:从获取到符号化分析
android·ios·小程序·https·uni-app·iphone·webview
ajassi20007 小时前
开源 Objective-C IOS 应用开发(二十一)自定义控件--示波器
ios·开源·objective-c
ajassi20007 小时前
开源 Objective-C IOS 应用开发(二十)多线程处理
ios·开源·objective-c
Q***l68717 小时前
后端服务网格可观测性,Jaeger追踪可观测性实践:Jaeger追踪详解
spring cloud·objective-c·p2p