1. 更新了Xcode11.0之后,在iOS13.0中presentViewController和之前彈出的樣式不一樣。
//恢復到之前樣式的解決方案:(設置VC.modalPresentationStyle)
viewcontroller *vc = [[viewcontroller alloc]init];
vc.modalPresentationStyle = UIModalPresentationFullScreen;
[weakSelf presentViewController:webView animated:YES completion:nil];
由于項目中,很多地方用了 presentViewController, 如果按上面的方法,要修改好多地方,于是...
采用分類的形式,給 UIViewController 增加一個分類,寫入方法
//Objective-C, 直接寫在 .m 中
@implementation UIViewController (iOS13)
- (UIModalPresentationStyle)modalPresentationStyle{
return UIModalPresentationFullScreen;
}
@end
OK ,運行起來 和之前一樣
2. 友盟崩潰問題
解決方案:更新最新的友盟SDK
3. 13.0暗黑模式來襲,
- 如何先屏蔽13.0的暗黑模式
//解決方案:info文件中加入
<key>UIUserInterfaceStyle</key>
<string>Light</string>
-
iOS 13 推出暗黑模式,UIKit 提供新的系統(tǒng)顏色和 api 來適配不同顏色模式,xcassets 對素材適配也做了調(diào)整,官方具體適配可見: Implementing Dark Mode on iOS。
參考鏈接:1.png
https://mp.weixin.qq.com/s/qliFbqRdkkE30vslojfJCA
https://juejin.im/post/5cf6276be51d455a68490b26
4. 增加了藍牙一直使用的權限請求
//解決方案:在info.plist里增加
<key>NSBluetoothAlwaysUsageDescription</key>
<string>我們想要一直使用您的藍牙功能來使定位更準確</string>
5. UITextField的私有KVC- (void)setValue:(nullable id)value forKeyPath:(NSString *)keyPath 會導致崩潰問題(其他的控件KVC可能也會導致崩潰問題,目前還未發(fā)現(xiàn),請謹慎使用)
//例如[_PhonetextField setValue:self.placeholdersColor forKeyPath:@"_placeholderLabel.textColor"];
//解決方案:NSMutableAttributedString *placeholderString = [[NSMutableAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName : self.placeholderColor}]; _textField.attributedPlaceholder = placeholderString;
6. iOS 13.0獲取deviceToken方法更改
//之前的獲取方式:
[[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""]
stringByReplacingOccurrencesOfString: @">" withString: @""]
stringByReplacingOccurrencesOfString: @" " withString: @""]
//13.0后的獲取方式:
if (![deviceToken isKindOfClass:[NSData class]]) return;
const unsigned *tokenBytes = [deviceToken bytes];
NSString *deviceTokens = [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(@"deviceTokens:_______________%@",deviceTokens);
7. iOS 13.0暗黑模式運行后發(fā)現(xiàn)狀態(tài)欄變?yōu)榘咨?,設置[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault不起作用
//解決方案:首先可能是 info.plist
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
//將false換成true可以設置全局為黑色,但是如果部分界面需要用到白色的狀態(tài)欄顏色,不能設置全局黑色,那么在最新的iOS13.0新增了狀態(tài)欄顏色屬性UIStatusBarStyleDarkContent
//在需要設置成黑色的控制器中加入iOS 13.0的判斷
-(void)viewWillAppear:(BOOL)animated{
if (@available(iOS 13.0, *)) {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDarkContent;
} else {
[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
}
8. 在最新的iOS13.0后蘋果強制加入了 Sign in with Apple(蘋果登錄),如果您的app中包含了其他的三方登錄,那么這個蘋果登錄也需要加進去。
Sign in with Apple接入流程:http://www.itdecent.cn/p/e1284bd8c72a
9. iOS 13.0以后,蘋果停止了對UIWebview的維護,將全面替換成WKWebview,app審核時會出現(xiàn)警告,但是可以繼續(xù)使用,聽說有的人因為UIWebView的問題審核被拒了,這個還有待更新。
h5的適配,參考鏈接:
https://blog.csdn.net/u012413955/article/details/92198556
10. iOS13.0,Xcode11 項目中使用SJVideoPlayer三方播放器的發(fā)生崩潰問題,
解決方案:替換三方庫里面的一個.m文件
點擊SJAVMediaMainPresenter.m.zip下載。(問題及解決方案在下面的鏈接里面)
https://github.com/changsanjiang/SJVideoPlayer/issues/153#issuecomment-534364750
11. UISegmentedControl 默認樣式改變
默認樣式變?yōu)榘椎缀谧?,如果設置修改過顏色的話,頁面需要修改。

原本設置選中顏色的 tintColor 已經(jīng)失效,新增了 selectedSegmentTintColor 屬性用以修改選中的顏色。
12. Xcode 11 創(chuàng)建的工程在低版本設備上運行黑屏
使用 Xcode 11 創(chuàng)建的工程,運行設備選擇 iOS 13.0 以下的設備,運行應用時會出現(xiàn)黑屏。這是因為 Xcode 11 默認是會創(chuàng)建通過 UIScene 管理多個 UIWindow 的應用,工程中除了 AppDelegate 外會多一個 SceneDelegate.

這是為了 iPadOS 的多進程準備的,也就是說 UIWindow 不再是 UIApplication 中管理。但是舊版本根本沒有 UIScene,因此解決方案就是在 AppDelegate 的頭文件加上:
@property (strong, nonatomic) UIWindow *window;
13. NSAttributedString優(yōu)化
對于UILabel、UITextField、UITextView,在設置NSAttributedString時也要考慮適配Dark Mode,否則在切換模式時會與背景色融合,造成不好的體驗
不建議的做法
NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:16]};
NSAttributedString *str = [[NSAttributedString alloc] initWithString:@"富文本文案" attributes:dic];
推薦的做法
// 添加一個NSForegroundColorAttributeName屬性
NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor labelColor]};
NSAttributedString *str = [[NSAttributedString alloc] initWithString:@"富文本文案" attributes:dic];
有其他的問題將持續(xù)更新!
[參考]
https://www.cnblogs.com/FZP5/p/11671241.html
http://www.itdecent.cn/p/8183d086b931
