当前位置: 首页 > news >正文

如何选择一家好的网站建设公司建网站的软件有哪些

如何选择一家好的网站建设公司,建网站的软件有哪些,做ui必要的网站,做外贸哪些网站可以发布产品ReactNative中升级IOS 17版本Crash解决 ReactNative中升级IOS 17版本Crash解决一、问题描述二、原因分析三、解决方案决策3.1 设置宽高为非零值3.2 使用新的UIGraphicsImageRenderer替换就版本的UIGraphicsBeginImageContext 四、可能使用到该API的三方库4.1 react-native-fast…

ReactNative中升级IOS 17版本Crash解决


在这里插入图片描述

    • ReactNative中升级IOS 17版本Crash解决
        • 一、问题描述
        • 二、原因分析
        • 三、解决方案决策
          • 3.1 设置宽高为非零值
          • 3.2 使用新的UIGraphicsImageRenderer替换就版本的UIGraphicsBeginImageContext
        • 四、可能使用到该API的三方库
          • 4.1 react-native-fast-image
          • 4.2 react-native-linear-gradient
          • 4.3 使用到 `UIGraphicsBeginImageContextWithOptions` 的三方库还有以下一些:
        • 五、参考地址

一、问题描述

业务上用了截图相关UIGraphicsBeginImageContextWithOptions && UIGraphicsEndImageContext 会报出 Assert。

错误信息会是下面这样:

  • UIGraphicsBeginImageContext() failed to allocate CGBitampContext: size={382, 0}, scale=3.000000, bitmapInfo=0x2002. Use UIGraphicsImageRenderer to avoid this assert.

或者会是这样的

  • *** Assertion failure in void _UIGraphicsBeginImageContextWithOptions(CGSize, BOOL, CGFloat, BOOL)(), UIGraphics.m:410
二、原因分析

查了下 api,发现 UIGraphicsBeginImageContext 在iOS 17上已经 deprecated 了. 点击这里,看看官方文档 官方文档说明https://developer.apple.com/documentation/uikit/1623922-uigraphicsbeginimagecontext

在这里插入图片描述

能够清楚地看到针对以下版本废弃

  • iOS 2.0–17.0 Deprecated
  • iPadOS 2.0–17.0 Deprecated
  • Mac Catalyst 13.1–17.0 Deprecated
  • tvOS 9.0–17.0 Deprecated
  • watchOS 2.0–10.0 Deprecated
  • visionOS 1.0–1.0 Deprecated
三、解决方案决策
3.1 设置宽高为非零值

当我们保证api 宽高不为零,则可正常使用,需要改动的地方较多,可能需要将业务中每一个设置为零属性的地方都得检查

3.2 使用新的UIGraphicsImageRenderer替换就版本的UIGraphicsBeginImageContext

改动较小,只需要改动三方库中原生内容即可,无需针对业务中涉及到的每一个元素进行校验,只需要验证部分页面展示正常即可。

四、可能使用到该API的三方库
4.1 react-native-fast-image

解决方案:react-native-fast-image 官方解决
修改node_modules文件路径: ios/FastImage/FFFastImageView.m


- (UIImage*) makeImage: (UIImage*)image withTint: (UIColor*)color {UIImage* newImage = [image imageWithRenderingMode: UIImageRenderingModeAlwaysTemplate];UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat defaultFormat];UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:image.size format:format];UIImage *resultImage = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull rendererContext) {CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);[color set];[newImage drawInRect:rect];}];return resultImage;
}
4.2 react-native-linear-gradient

官方解决方案: react-native-linear-gradient 官方解决

按照官方解决,已经提供了新的版本包在npm仓库,此时我们可以去更新源代码或者直接更新版本:

  • 下载是最新的版本
    下载最新版本地址:https://github.com/react-native-linear-gradient/react-native-linear-gradient/releases/tag/v2.8.3
    也可以直接去看看npm仓库。

  • 直接更新源码

如果要更新源代码,则进行更新路径/node_modules/react-native-linear-gradient/ios/BVLinearGradientLayer.m 文件中 display函数。


- (void)display {[super display];// short circuit when height or width are 0. Fixes CGContext errors throwingif (self.bounds.size.height == 0 || self.bounds.size.width == 0) {return;}BOOL hasAlpha = NO;for (NSInteger i = 0; i < self.colors.count; i++) {hasAlpha = hasAlpha || CGColorGetAlpha(self.colors[i].CGColor) < 1.0;}if (@available(iOS 10.0, *)) {UIGraphicsImageRendererFormat *format;if (@available(iOS 11.0, *)) {format = [UIGraphicsImageRendererFormat preferredFormat];} else {format = [UIGraphicsImageRendererFormat defaultFormat];}format.opaque = !hasAlpha;UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:self.bounds.size format:format];UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull ref) {[self drawInContext:ref.CGContext];}];self.contents = (__bridge id _Nullable)(image.CGImage);self.contentsScale = image.scale;} else {UIGraphicsBeginImageContextWithOptions(self.bounds.size, !hasAlpha, 0.0);CGContextRef ref = UIGraphicsGetCurrentContext();[self drawInContext:ref];UIImage *image = UIGraphicsGetImageFromCurrentImageContext();self.contents = (__bridge id _Nullable)(image.CGImage);self.contentsScale = image.scale;UIGraphicsEndImageContext();}
}

我项目中闪退的就是这个库出的问题,当渐变的文本有内容时,则展示是正常的,但是当文本内容不存在时,就会出现闪退,这就很诡异。

4.3 使用到 UIGraphicsBeginImageContextWithOptions 的三方库还有以下一些:
  • react native本身绘画边框
  • react-native本身图片处理 /node_modules/react-native/Libraries/Image/RCTImageUtils.m
  • react-native-camera
  • react-native-view-shot
  • react-native-svg 文件包含地址: node_modules/react-native-svg/apple/RNSVGRenderable.mm
  • react-native-syan-image-picker 中 TZImagePickerController

其他三方库没有列出来,可以在Xcode中进行搜索 UIGraphicsBeginImageContextWithOptions ,检查是否是有使用到,同时验证显示正常与否。如果显示有问题,则可以去三方库对应的官方Github寻求解决方案或者自行替换。

五、参考地址

Apple官方提问:https://developer.apple.com/forums/thread/733326
Apple官方提问:https://developer.apple.com/forums/thread/731385
github issue:https://github.com/react-native-linear-gradient/react-native-linear-gradient/issues/637


http://www.hkea.cn/news/412692/

相关文章:

  • 山东滕州疫情最新消息今天i长沙官网seo
  • 公司做网站买域名之后做什么百度一下你就知道手机版
  • 北京婚恋网站哪家最好企业推广宣传方式
  • 国发网站建设西安做网站公司
  • 网站推广服务合同简述网络营销的主要方法
  • 信息门户网站是什么成人计算机培训机构哪个最好
  • 网站建设公司 中企动力公司东莞商城网站建设
  • b2c的电子商务网站自己想做个网站怎么做
  • 京东pc网站用什么做的如何注册网站怎么注册
  • 长沙商城网站制作seo线下培训课程
  • web网站开发公司网站制作优化排名
  • 这么做3d网站企业邮箱网页版
  • 瑞安网站建设公司关键词排名网络推广
  • 南京学做网站友情链接检查工具
  • 参考文献网站开发百度重庆营销中心
  • 如何做微信ppt模板下载网站企业网页设计公司
  • 做b2b网站百度点击快速排名
  • 网站怎么做移动图片不显示不出来吗芭嘞seo
  • 旅游网站建设服务器ip域名解析
  • 企业网站建设三个原则百度指数资讯指数是指什么
  • 房地产集团网站建设方案软文文案案例
  • 阜蒙县建设学校网站是什么北京seo编辑
  • 珠海建设局网站十大经典事件营销案例分析
  • 创建网站开发公司互联网推广引流是做什么的
  • 万盛集团网站建设seo网站推广全程实例
  • 做教育的网站需要资质吗网站怎么开发
  • 微网站怎么做滚动中国万网域名注册官网
  • 个人如何免费建网站seo在线优化工具 si
  • 双线主机可以做彩票网站吗网络推广合作协议
  • 做外贸的b2b网站域名批量查询系统