1.tableView
向下偏移,部分UIScrollView
布局出现混乱。
原因:
因iOS11
弃用了automaticallyAdjustsScrollViewInsets
使用了contentInsetAdjustmentBehavior
代替。
解决方法如下,其中
@available(iOS 11.0, *)
表示在iOS11
版本以上可用。
if (@available(iOS 11.0, *)) {
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else{
self.automaticallyAdjustsScrollViewInsets = NO;
}
当然我们可以定义个宏
#define KAdjustsScrollViewInsets_NO(scrollView,vc)\
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") \
if (@available(iOS 11.0,*)) {\
scrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;\
} else {\
self.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
2.TableView
的区头、区尾、cell
高度变大。
原因:因为
TaBleView
的estimatedRowHeight
、estimatedSectionHeaderHeight
、estimatedSectionFooterHeight
三个高度由默认的0
变成了UITableViewAutomaticDimension
,导致了高度计算不对。
解决方法:
在相应界面,将三个属性都设为
0
;
if (@available(iOS 11.0, *)) {
_tableView.estimatedRowHeight = 0;
_tableView.estimatedSectionHeaderHeight = 0;
_tableView.estimatedSectionFooterHeight = 0;
}
为了方便我们也可以定义宏
#define TableViewCloseTheEstimate(tableView)\
if (@available(iOS 11.0, *)) {\
tableView.estimatedRowHeight = 0;\
tableView.estimatedSectionHeaderHeight = 0;\
tableView.estimatedSectionFooterHeight = 0;\
}
当然我们如果想全局都将这三个属性设为
0
,也可以在AppDelegate.m
中进行全局设置。
if (@available(iOS 11.0, *)) {
[UITableView appearance].estimatedRowHeight = 0;
[UITableView appearance].estimatedSectionHeaderHeight = 0;
[UITableView appearance].estimatedSectionFooterHeight = 0;
}
3.部分Block
警告

例如:

原因:定义未带参数的
Block
时,Xcode9
中会报上面错误。
解决方法:
- 参数位置为
void
。 - 部分第三方也有此种警告。你不可能一个个去修改修改,所以我们需要在
Build Setting
——>Other Warning Flags
中添加:-Wno-strict-prototypes
,然后再Clean
、Build
。这种方法只是屏蔽警告……

4.ReactiveCocoa Unknown warning group '-Wreceiver-is-weak',ignored
警告
原因:之前的
Xcode
中如果消息的接收者是一个weak
对象时,clang
编译器会报receiver-is-weak
警告,所以在ReactiveCocoa
中添加了下方的push
&pop
以消除警告。而在Xcode9
中clang
已经把这个警告给移除,所以再添加下方push
&pop
就会有警告。
#define RACObserve(TARGET, KEYPATH) \
({ \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wreceiver-is-weak\"") \
__weak id target_ = (TARGET); \
[target_ rac_valuesForKeyPath:@keypath(TARGET, KEYPATH) observer:self]; \
_Pragma("clang diagnostic pop") \
})
解决方法:
将
pod 'ReactiveCocoa', '2.5'
换成下方。
pod 'ReactiveCocoa', :git => 'https://github.com/zhao0/ReactiveCocoa.git', :tag => '2.5.2'
5. 友盟社会化组件在Xcode9
上无法编译。
Pods/UMengSocialCOM/Umeng_SDK_Social_iOS_ARM64_5.2.1/UMSocial_Sdk_5.2.1/SocialSDKXib/UMSCommentDetailController.xib: warning: Internationalization is not available when compiling for targets before iOS 6.0
原因:之前引用的
pod 'UMengSocialCOM', '~> 5.2.1'
,此版本友盟已不再维护,替换成UMengUShare
。
因项目中只使用了微信
、微博
、Podfile
文件中将pod 'UMengSocialCOM', '~> 5.2.1'
替换为👇
#友盟社会化组件
pod 'UMengUShare/Network', '~> 6.4.5'
pod 'UMengUShare/Core', '~> 6.4.5'
pod 'UMengUShare/UI', '~> 6.4.5'
pod 'UMengUShare/Plugin', '~> 6.4.5'
pod 'UMengUShare/Social/WeChat', '~> 6.4.5'
pod 'UMengUShare/Social/QQ', '~> 6.4.5'
pod 'UMengUShare/Social/Sina', '~> 6.4.5'
同时为了后期的维护,我们对所需要用到的接口进行了二次封装;
6.iPhone X
中 TabBar
下方多了一条透明区域。
原因:
iPhone X
的底部是预留给系统功能的一个区域Home Indicator
, 高度34pt
。如果使用的系统的TabBar
,那么Home Indicator
就会延展相应的barTintColor
,而我们使用是自定义的。
解决方法:
我们在所以ViewContrller
继承的基类BaseViewController
中添加了self.edgesForExtendedLayout = UIRectEdgeNone
;
- (instancetype) init {
self = [super init];
if (self) {
self.edgesForExtendedLayout = UIRectEdgeNone;
}
return self;
}
修改完后,布局可能有所变化。
就比如我们的一些布局为:make.top.equalTo(self.view.top).offset(kNavigationAndStatusBarHeight)
; 需要改为:make.top.equalTo(self.view.top)
;
7.iPhone X
中状态栏高度变高
原因:
iPhone X
全面屏,增加了刘海儿
,高度从之前的20pt
变成了44pt
。
所以我们定义宏的时候就不能直接写死。
解决方法:
#define kStatusBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height)
同时补上定义的其他宏
#define kStatusBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height)
#define kNavigationBarHeight 44.f
#define kNavigationAndStatusBarHeight (kStatusBarHeight + 44.f)
#define kTabBarHeight 49.f
#define KiPhoneXTabBarHeight (34.f + 49.f)
#define KHomeIndicatorHeight 34.f
#define kSCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define kSCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
// iPhone5 or iPhone5s
#define iPhone5_5s_SE (kSCREEN_WIDTH == 320.f && kSCREEN_HEIGHT == 568.f)
//iPhone6 or iPhone6s or iPhone7 or iPhone8
#define iPhone6_6s_7_8 (kSCREEN_WIDTH == 375.f && kSCREEN_HEIGHT == 667.f)
//iPhone6Plus or iPhone6sPlus or iPhone7Plus or iPhone8Plus
#define iPhone6Plus_6sPlus_7Plus_8Plus (kSCREEN_WIDTH == 414.f && kSCREEN_HEIGHT == 736.f)
//iPhone X
#define iPhoneX (kSCREEN_WIDTH == 375.f && kSCREEN_HEIGHT == 812.f)
网友评论