问题及解决
- 问题
开发中,遇到在代码中使用mas_bottomMargin崩溃的问题。 -
解决方法
修改Masonry Target最低支持版本为iOS8.0以上
三方库Target最低版本.png
原因分析及进一步优化处理
- 原因
mas_bottomMargin等几个属性定义依靠的是最低支持版本至少是8.0。
#if (__IPHONE_OS_VERSION_MIN_REQUIRED >= 80000) || (__TV_OS_VERSION_MIN_REQUIRED >= 9000)
@property (nonatomic, strong, readonly) MASViewAttribute *mas_leftMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_rightMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_topMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_bottomMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_leadingMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_trailingMargin;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerXWithinMargins;
@property (nonatomic, strong, readonly) MASViewAttribute *mas_centerYWithinMargins;
#endif
- 优化处理
为了防止其它Pod安装的三方库遇到类似问题,可以在Podfifle文件最后统一修改为三方库最低支持iOS版本与app保持一致, 比如app最低支持iOS9.0的写法如下
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
end
end
end
网友评论