1、UITextField 通过KVC方式修改_placeholderLabel.textColor崩溃
[_textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];///崩溃
[_textField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];///崩溃
_textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"姓名" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14],NSForegroundColorAttributeName:[UIColor redColor]}]; ///新的实现
在Xcode10上编译不会有问题,但是在Xcode11上编译的会崩溃。并且- (void)setValue:(nullable id)value forKey:(NSString *)key
方法没问题,- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath
会崩溃。
2、+[_LSDefaults sharedInstance] 崩溃问题
崩溃原因:友盟SDK问题
解决办法:升级友盟SDK,https://info.umeng.com/detail?id=177&&cateId=1
3、presentViewController 默认样式的变化
在iOS 13之前,presentViewController展示的视图默认是全屏的:
iOS13中,默认的样式变成了类iPhone上safari的分页样式:
在使用 presentViewController
来跳转视图时系统提供了两个参数来简化跳转的设置,modalTransitionStyle
和 modalPresentationStyle
。前者为转场过渡的类型,后者为展示的样式,系统为两者都提供了多种可选样式。
在iOS13前,如果没有定义 modalPresentationStyle
这个属性的话,系统会默认给 fullScreen
,但是在iOS13中如果不定义的话,系统默认的是
@available(iOS 13.0, *)
case automatic
所以为了正常全屏显示,那么每次的 present
方法建议提前设置好modalPresentationStyle
//swift
let mainViewController = UIView() // 即需要被present的view
mainViewController.modalPresentationStyle = .fullScreen
self.present(mainViewController, animated: true, completion: nil)
//oc
UIViewController *vc = [[UIViewController alloc] init]; // vc即需要被present的viewcontroller
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentViewController:vc animated:YES completion:nil];
4、强行设置App模式
当系统设置为Dark Mode时,对某些App的个别页面希望一直显示Light Mode下的样式,这个时候就需要强行设置当前ViewController的模式了
// 设置当前view或viewCongtroller的模式
@property(nonatomic) UIUserInterfaceStyle overrideUserInterfaceStyle;
示例
// 设置为Light Mode即可
[self setOverrideUserInterfaceStyle:UIUserInterfaceStyleLight];
注意⚠️:
- 当我们强行设置当前
viewController
为Light Mode
后,这个viewController
下的view
都是Light Mode
- 由这个ViewController
present
出的`ViewController不会受到影响,依然跟随系统的模式
要想一键设置App下所有的ViewController都是Light Mode,直接在Window上设置 overrideUserInterfaceStyle
if #available(iOS 13.0, *) {
window?.overrideUserInterfaceStyle = .light
}
或者在项目Info.plist里面设置 User Interface Style
注意:对
window.rootViewController
强行设置Dark Mode
也不会影响后续present
出的ViewController
的模式
5、UISearchBar通过[searchBar valueForKey:@"_searchField"]获取searchTextField
崩溃
原因:searchTextField
属性对外暴露了,不用再通过KVC获取了。
解决方法:
UISearchBar *searchBar = [[UISearchBar alloc]init];
UITextField *searchTextField = [[UITextField alloc] init];
if(@available(iOS 13.0, *)){
searchTextField = searchBar.searchTextField;
} else {
searchTextField = [searchBar valueForKey:@"_searchField"];
}
UISearchBar *searchBar = [[UISearchBar alloc]init];
6、UITabBar的title颜色被还原成系统默认色
iOS13 之前用以下方法来设置 tabbarItem
的 title
颜色
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor yellowColor], NSForegroundColorAttributeName,
nil] forState: UIControlStateNormal];
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor redColor], NSForegroundColorAttributeName,
nil] forState:UIControlStateSelected];
但是在 iOS13
运行项目时发现,在从A页面Push B页面隐藏tabbar
后返回,点击tabbarItem
时title
的颜色被重置成系统色值。
解决办法:用下面方法设置title
的默认颜色
if (@available(iOS 10.0, *)) {
[[UITabBar appearance] setUnselectedItemTintColor:UIColorFromRGBWithAlpha(0x666666,1.0)];
}
7、高德地图定位Crash
解决办法:升级SDK,目前高德SDK V2.6.3 已适配iOS13系统
8、StatusBar相关监听名变更
// 设备方向将要改变
UIKIT_EXTERN NSNotificationName const UIApplicationWillChangeStatusBarOrientationNotification API_UNAVAILABLE(tvos) API_DEPRECATED("Use viewWillTransitionToSize:withTransitionCoordinator: instead.", ios(2.0, 13.0));
//设备方向改变
UIKIT_EXTERN NSNotificationName const UIApplicationDidChangeStatusBarOrientationNotification API_UNAVAILABLE(tvos) API_DEPRECATED("Use viewWillTransitionToSize:withTransitionCoordinator: instead.", ios(2.0, 13.0));
UIKIT_EXTERN NSString *const UIApplicationStatusBarOrientationUserInfoKey API_UNAVAILABLE(tvos) API_DEPRECATED("Use viewWillTransitionToSize:withTransitionCoordinator: instead.", ios(2.0, 13.0));
//设备状态栏frame将要改变
UIKIT_EXTERN NSNotificationName const UIApplicationWillChangeStatusBarFrameNotification API_UNAVAILABLE(tvos) API_DEPRECATED("Use viewWillTransitionToSize:withTransitionCoordinator: instead.", ios(2.0, 13.0));
//设备状态栏frame改变
UIKIT_EXTERN NSNotificationName const UIApplicationDidChangeStatusBarFrameNotification API_UNAVAILABLE(tvos) API_DEPRECATED("Use viewWillTransitionToSize:withTransitionCoordinator: instead.", ios(2.0, 13.0));
UIKIT_EXTERN NSString *const UIApplicationStatusBarFrameUserInfoKey API_UNAVAILABLE(tvos) API_DEPRECATED("Use viewWillTransitionToSize:withTransitionCoordinator: instead.", ios(2.0, 13.0)); // userInfo dictionary key for status bar frame
持续更新中…