問題及解決
- 問題
開發(fā)中,遇到在代碼中使用mas_bottomMargin崩潰的問題。 -
解決方法
修改Masonry Target最低支持版本為iOS8.0以上
三方庫Target最低版本.png
原因分析及進(jìn)一步優(yōu)化處理
- 原因
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
- 優(yōu)化處理
為了防止其它Pod安裝的三方庫遇到類似問題,可以在Podfifle文件最后統(tǒng)一修改為三方庫最低支持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
