Xcode11 缺失库文件导入位置变更
Xcode11下 这个目录不存在了
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
【变更为】
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
----以下位置不需要改变
/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
友盟分享 注册新浪平台 崩溃【验证:仅在模拟器上出现】
这个应该是需要微博官方进行适配了,尝试模拟了 getUniqueStrByUUID
中的相关写法,无果。
+[_LSDefaults sharedInstance] 崩溃问题
暂时的处理手段
@implementation NSObject (Extend)
+ (void)load{
SEL originalSelector = @selector(doesNotRecognizeSelector:);
SEL swizzledSelector = @selector(sw_doesNotRecognizeSelector:);
Method originalMethod = class_getClassMethod(self, originalSelector);
Method swizzledMethod = class_getClassMethod(self, swizzledSelector);
if(class_addMethod(self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))){
class_replaceMethod(self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
}else{
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
+ (void)sw_doesNotRecognizeSelector:(SEL)aSelector{
//处理 _LSDefaults 崩溃问题
if([[self description] isEqualToString:@"_LSDefaults"] && (aSelector == @selector(sharedInstance))){
//冷处理...
return;
}
[self sw_doesNotRecognizeSelector:aSelector];
}
UITextField 通过KVC方式修改空白提示语颜色 崩溃
[UITextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor”];
解决方案:
attributedPlaceholder
控制器模态跳转异常
疑似过场动画上下文机制有调整,默认调整为了卡片样式。
/*
Defines the presentation style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter.
If this property has been set to UIModalPresentationAutomatic, reading it will always return a concrete presentation style. By default UIViewController resolves UIModalPresentationAutomatic to UIModalPresentationPageSheet, but other system-provided view controllers may resolve UIModalPresentationAutomatic to other concrete presentation styles.
Defaults to UIModalPresentationAutomatic on iOS starting in iOS 13.0, and UIModalPresentationFullScreen on previous versions. Defaults to UIModalPresentationFullScreen on all other platforms.
*/
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle API_AVAILABLE(ios(3.2));
[nav setModalPresentationStyle:UIModalPresentationFullScreen];
Dark Mode 颜色主题相关
UIColor *dynamicColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * provider) {
//使用 provider 判断,有时会出问题
if(keyWindow.isDark){
return darkColor;
}
return lightColor;
}];
UIImageView
//1. 初始化问题
UIImageView.image 初始化时必须设置,否则不显示
//2. 暗黑适配问题 [图片经过拉伸处理后,会导致暗黑适配失效]
UIImage *image = [image stretchableImageWithLeftCapWidth:0 topCapHeight:top];
self.imageView.image = image;
UIWindow 变更
在iOS13版本下,App 任意处生成YYTextView均会导致全局的scrollsToTop 回顶功能失效。
虽然最终追查至YYTextEffectWindow
中,但整个排查过程还是发现了很多新内容的。
这是正常的回顶功能调用逻辑,基于此一条条的覆写了系统相关的私有函数来判别问题出自何处。
-[UICollectionView scrollViewShouldScrollToTop:]
-[UIScrollView _scrollToTopIfPossible:] ()
-[UIScrollView _scrollToTopFromTouchAtScreenLocation:resultHandler:] ()
-[UIWindow _scrollToTopViewsUnderScreenPointIfNecessary:resultHandler:]_block_invoke.796 ()
-[UIWindow _handleScrollToTopAtXPosition:resultHandler:] ()
//此处能看到有个新鲜的 UIStatusBarManager 是iOS13新增的类,可以看到状态栏的点击事件已经被其接管了。
//经过实践,出问题的时候该方法也能被正常调用故此排上以上调用栈方法。
-[UIStatusBarManager _handleScrollToTopAtXPosition:] ()
-[UIStatusBarManager handleTapAction:] ()
开始以为是多个UIScrollView共存时scrollsToTop
的设置问题,还有UIScrollViewContentInsetAdjustmentNever
的设置问题。结果都不是...
最终沿着UIScrollView 子类一直查找,找到了YYTextView
其中用到的 YYTextEffectWindow
也进入了视野...
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
if (![UIApplication isAppExtension]) {
one = [self new];
one.frame = (CGRect){.size = kScreenSize};
one.userInteractionEnabled = NO;
//此处能看到 窗口等级是高于状态栏的,但多次尝试等级调整均无果。
one.windowLevel = UIWindowLevelStatusBar + 1;
//元凶在这里
//所以,即使关闭了用户交互 但是它竟能够阻挡状态栏的事件,但却对常规Window的事件无任何影响...
if (@available(iOS 13.0, *)) {
//费解的结果...
one.hidden = YES;
}else{
one.hidden = NO;
}
// for iOS 9:
one.opaque = NO;
one.backgroundColor = [UIColor clearColor];
one.layer.backgroundColor = [UIColor clearColor].CGColor;
}
});
return one;
在UIWindow 上使用addSubview添加子视图,需要注意 暗黑模式切换,并不会向子视图下发状态变更。
解决办法:
获取系统暗黑切换通知(自行实现),然后重写添加到 UIWindow 的子视图 overrideUserInterfaceStyle 为正确的状态。
状态栏相关
- 获取状态栏
if (@available(iOS 13.0, *)) {
UIView *_localStatusBar = [[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager performSelector:@selector(createLocalStatusBar)];
UIView * statusBar = [_localStatusBar performSelector:@selector(statusBar)];
// 注意此代码不生效
// [statusBar drawViewHierarchyInRect:statusBar.bounds afterScreenUpdates:NO];
[statusBar.layer renderInContext:context];
} else {
// Fallback on earlier versions
}
UIScrollView 滚动条异常偏移
屏幕旋转可能会触发系统对滚动条的自动修正
如果没有修改需求,关闭该特性即可
#ifdef __IPHONE_13_0
if (@available(iOS 13.0, *)) {
self.automaticallyAdjustsScrollIndicatorInsets = NO;
}
#endif
UICollectionView 异常API
该API 在iOS13下会强制将cell置中,导致上部留白。
推测,底部应该也会有留白的情况。
#pragma mark - 修复iOS13 下滚动异常API
#ifdef __IPHONE_13_0
- (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated{
[super scrollToItemAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
//修复13下 图片滚动位置异常
//顶部
if(self.contentOffset.y < 0){
[self setContentOffset:CGPointZero];
return;
}
//底部
if(self.contentOffset.y > self.contentSize.height){
[self setContentOffset:CGPointMake(0, self.contentSize.height)];
}
}
#endif
UITableViewCell 异常 【疑似iOS13beta4新出现】
[self addSubView: viewObjA]
[self.contentView addSubview:viewObjB]
上面两种方式,在遇到折叠需求时。设置self.clipsToBounds=YES 可能会有布局异常
//保险的做法
self.clipsToBounds = YES; 【无效】
//此处很费解
self.layer.masksTobounds = YES; 【有效】
疑似布局引擎机制有调整 【有待确定】
在调试中发现,如果代码流是这样一种状态 可能会造成 【约束失效】
如果遇到诡异问题 需要排查下是否存在约束和绝对布局混用的情况
[viewMain addSubView:viewA];
[viewMain addSubView:viewB];
// 更新 viewA 的约束
[self.imageBackground mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(50);
}];
//立即更新约束
[viewA.superview setNeedsUpdateConstraints];
[viewA.superview updateConstraintsIfNeeded];
[viewA.superview layoutIfNeeded];
//更新容器约束
[viewMain mas_updateConstraints:^(MASConstraintMaker *make) {
make....
}];
....
其它处理逻辑
....
// 更新 viewA 的约束 【代码不会生效】
[self.imageBackground mas_updateConstraints:^(MASConstraintMaker *make) {
make.top.mas_equalTo(100);
}];
UITextField 异常 【疑似iOS13beta4新出现】
在设置
leftView
左按钮时,如果使用的是UIImageView
即会出现图片无法按照意图显示的问题。
// Confuse in beta4 iOS13
UIImageView *imageIcon = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 34, 30)];
//search_icon 15*15
imageIcon.image = [UIImage imageNamed:@"search_icon"];
imageIcon.contentMode = UIViewContentModeCenter;
UITextField *txtSearch = [[UITextField alloc] init];
txtSearch.leftView = imageIcon;
WKWebView 暗黑适配
要点:
- 模式参数通过 UA 传递
- 联调中出现加载闪白问题
webView.opaque = false;
网友评论