iOS13問題總結(jié)

1.控制器的 modalPresentationStyle 默認(rèn)值變了
查閱了下 UIModalPresentationStyle枚舉定義,赫然發(fā)現(xiàn)iOS 13新加了一個(gè)枚舉值:
typedef NS_ENUM(NSInteger, UIModalPresentationStyle) {
UIModalPresentationFullScreen = 0,
UIModalPresentationPageSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
UIModalPresentationFormSheet API_AVAILABLE(ios(3.2)) API_UNAVAILABLE(tvos),
UIModalPresentationCurrentContext API_AVAILABLE(ios(3.2)),
UIModalPresentationCustom API_AVAILABLE(ios(7.0)),
UIModalPresentationOverFullScreen API_AVAILABLE(ios(8.0)),
UIModalPresentationOverCurrentContext API_AVAILABLE(ios(8.0)),
UIModalPresentationPopover API_AVAILABLE(ios(8.0)) API_UNAVAILABLE(tvos),
UIModalPresentationBlurOverFullScreen API_AVAILABLE(tvos(11.0)) API_UNAVAILABLE(ios) API_UNAVAILABLE(watchos),
UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,
UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,
};

解決方案
如果你完全接受蘋果的這個(gè)默認(rèn)效果,那就不需要去修改任何代碼。
如果,你原來就比較細(xì)心,已經(jīng)設(shè)置了modalPresentationStyle的值,那你也不會(huì)有這個(gè)影響。
對(duì)于想要找回原來默認(rèn)交互的同學(xué),直接設(shè)置如下即可:

self.modalPresentationStyle = UIModalPresentationOverFullScreen;
在使用 presentViewController 來跳轉(zhuǎn)視圖時(shí)系統(tǒng)提供了兩個(gè)參數(shù)來簡(jiǎn)化跳轉(zhuǎn)的設(shè)置,modalTransitionStyle 和modalPresentationStyle前者為轉(zhuǎn)場(chǎng)過渡的類型,后者為展示的樣式,系統(tǒng)為兩者都提供了多種可選樣式。
modalPresentationStyle在iOS13前該值默認(rèn)為UIModalPresentationFullScreen;而在 iOS13 中變?yōu)榱薝IModalPresentationAutomatic,因此會(huì)導(dǎo)致如上問題。
解決方法:在presentViewController的時(shí)候?qū)⒖刂破鱩odalPresentationStyle設(shè)置為UIModalPresentationFullScreen 即
vc.modalPresentationStyle = UIModalPresentationFullScreen;

2.MPMoviePlayerController 在iOS 13已經(jīng)不能用了
'MPMoviePlayerController is no longer available. Use AVPlayerViewController in AVKit.'

解決方案:
既然不能再用了,那只能換掉了。替代方案就是AVKit里面的那套播放器。

3.iOS 13 DeviceToken有變化
NSString *dt = [deviceToken description];
dt = [dt stringByReplacingOccurrencesOfString: @"<" withString: @""];
dt = [dt stringByReplacingOccurrencesOfString: @">" withString: @""];
dt = [dt stringByReplacingOccurrencesOfString: @" " withString: @""];
這段代碼運(yùn)行在 iOS 13 上已經(jīng)無法獲取到準(zhǔn)確的DeviceToken字符串了,iOS 13 通過[deviceToken description]獲取到的內(nèi)容已經(jīng)變了。
解決方案

  • (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);
    }

4.Sign in with Apple -提供第三方登錄的注意啦
如果你的應(yīng)用使用了第三方登錄,那么你可能也需要加下 「Sign in with Apple」
Sign In with Apple will be available for beta testing this summer. It will be required as an option for users in apps that support third-party sign-in when it is commercially available later this year.

5.即將廢棄的 LaunchImage
從 iOS 8 的時(shí)候,蘋果就引入了 LaunchScreen,我們可以設(shè)置 LaunchScreen來作為啟動(dòng)頁。當(dāng)然,現(xiàn)在你還可以使用LaunchImage來設(shè)置啟動(dòng)圖。不過使用LaunchImage的話,要求我們必須提供各種屏幕尺寸的啟動(dòng)圖,來適配各種設(shè)備,隨著蘋果設(shè)備尺寸越來越多,這種方式顯然不夠 Flexible。而使用 LaunchScreen的話,情況會(huì)變的很簡(jiǎn)單, LaunchScreen是支持AutoLayout+SizeClass的,所以適配各種屏幕都不在話下。
注意啦??,從2020年4月開始,所有使? iOS13 SDK的 App將必須提供 LaunchScreen,LaunchImage即將退出歷史舞臺(tái)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容