1.KVC訪問私有屬性的崩潰問題
在Xcode11上使用- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath
方法訪問私有屬性,編譯時會崩潰,例
[textField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];///崩潰 [textField setValue:[UIFont systemFontOfSize:14] forKeyPath:@"_placeholderLabel.font"];///崩潰
不過使用- (void)setValue:(nullable id)value forKey:(NSString *)key
方法正常,例如:
[self setValue:baseTabBar forKey:@"tabBar"]; //正常
2.即將廢棄的LaunchImage
隨着蘋果設備的型號日益增多,利用LaunchImage來設置啟動圖顯然顯得不夠明智。
替代方式:使用LaunchScreen來設置啟動圖。LaunchScreen是iOS8引入的,支持AutoLayout+SizeClass,所以用起來十分方便。據消息,明年4月份后,所有app必須提供LaunchScreen了,盡早替換吧。
3.完全廢棄的UIWebView
隨着iOS13的到來,UIWebView的使用范圍定格在了iOS12。很早時間之前UIWebView就因存在內存泄漏問題被蘋果建議用WKWebView來替代。此次更是完全被廢棄。現在上傳AppStore的應用如果存在UIWebView,蘋果會給你發郵件告訴你,UIWebView的API已經廢棄了。So,趕緊替換。
4.presentViewController的問題
iOS 13 的 presentViewController 默認有視差效果,模態出來的界面現在默認都下滑返回。 一些頁面必須要點確認才能消失的,需要適配。如果項目中頁面高度全部是屏幕尺寸,那么多出來的導航高度會出現問題。所以手動設置一下Style吧
self.modalPresentationStyle = UIModalPresentationFullScreen;
5.暗黑模式的適配
隨着iOS13的到來,有了暗黑模式,需要我們開發者花更多精力去適配,尤其是那些重量級項目,很費時間。這里先不談適配問題,以后再談。如果不適配的話需要你全局關閉暗黑模式。
方法:配置plist文件: 在Info.plist 文件中,添加UIUserInterfaceStyle key 名字為 User Interface Style 值為String,將UIUserInterfaceStyle key 的值設置為 Light。
6.增加藍牙權限申請
iOS13以前,使用藍牙時可以直接用,不會出現權限提示,iOS13后,再使用就會提示了。 在info.plist里增加
<key>NSBluetoothAlwaysUsageDescription</key> <string>我們需要使用您的藍牙</string>`
7.DeviceToken 獲取
DeviceToken 獲取到的格式發生變化
#include <arpa/inet.h> - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { if (![deviceToken isKindOfClass:[NSData class]]) return; const unsigned *tokenBytes = [deviceToken bytes]; NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x", ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]), ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]), ntohl(tokenBytes[6]), ntohl(tokenBytes[7])]; NSLog(@"deviceToken:%@",hexToken); }
8.MPMoviePlayerController 徹底棄用
MPMoviePlayerController 在 iOS 9 開始被棄用,如果在 iOS 13 中繼續使用的話會直接拋出異常:
9.UISearchDisplayController徹底棄用
在 iOS 8 之前,我們在 UITableView 上添加搜索框需要使用 UISearchBar + UISearchDisplayController 的組合方式。
在 iOS 8 之后,蘋果就已經推出了 UISearchController 來代替這個組合方式。在 iOS 13 中,如果還繼續使用 UISearchDisplayController會直接導致崩潰,崩潰信息如下
Terminating app due to uncaught exception 'NSGenericException', reason: 'UISearchDisplayController is no longer supported when linking against this version of iOS. Please migrate your application to UISearchController.'
10.[UIApplication sharedApplication].keyWindow API將被棄用
@property(nullable, nonatomic,readonly) UIWindow *keyWindow API_DEPRECATED("Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes", ios(2.0, 13.0));
修改使用下方代碼獲取
[[[UIApplication sharedApplication] windows] objectAtIndex:0]
原文出處https://www.jianshu.com/p/4409ccf98070