iOS13 適配和Xcode11.0踩坑小結(jié)
iOS13中presentViewController的問(wèn)題
更新了Xcode11.0 beta之后,在iOS13中運(yùn)行代碼發(fā)現(xiàn)presentViewController和之前彈出的樣式不一樣。

會(huì)出現(xiàn)這種情況是主要是因?yàn)槲覀冎皩?duì)UIViewController里面的一個(gè)屬性,即modalPresentationStyle(該屬性是控制器在模態(tài)視圖時(shí)將要使用的樣式)沒(méi)有設(shè)置需要的類(lèi)型。在iOS13中modalPresentationStyle的默認(rèn)改為UIModalPresentationAutomatic,而在之前默認(rèn)是UIModalPresentationFullScreen。
/* 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));
要改會(huì)原來(lái)模態(tài)視圖樣式,我們只需要把UIModalPresentationStyle設(shè)置為UIModalPresentationFullScreen即可。
ViewController *vc = [[ViewController alloc] init]; vc.title = @"presentVC"; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc]; nav.modalPresentationStyle = UIModalPresentationFullScreen; [self.window.rootViewController presentViewController:nav animated:YES completion:nil];

私有KVC
在使用iOS 13運(yùn)行項(xiàng)目時(shí)突然APP就crash掉了。定位到的問(wèn)題是在設(shè)置UITextField的Placeholder也就是占位文本的顏色和字體時(shí)使用了KVC的方法:
[_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]}];
并且只需要在初始化的時(shí)候設(shè)置attributedPlaceholder即富文本的占位文本,再重新賦值依然使用placeolder直接設(shè)置文本內(nèi)容,樣式不會(huì)改變。(想要這種效果的話(huà)需要在初始化attributedPlaceholder時(shí)的字符串不為空)
Universal Link(通用鏈接)
在Xcode11中配置Universal Link(通用鏈接)步驟:

在iOS13之前在其他APP去safari中打開(kāi)Universal Link(通用鏈接)系統(tǒng)匹配域名是全匹配,而在iOS13之后規(guī)則發(fā)生了變化,猜測(cè)是包含關(guān)系。比如在iOS13之前,如果Universal Link(通用鏈接)為w.mydomain.com那么在微信或者其他APP訪(fǎng)問(wèn)www.mydomain.com然后點(diǎn)擊去safari打開(kāi)則不會(huì)拉起相應(yīng)APP,而在iOS13則會(huì)拉起相應(yīng)APP。
而在safari中輸入的鏈接則依然和iOS之前一樣,只有www.mydomain.com才會(huì)提示打開(kāi)相應(yīng)APP。
修改APP名稱(chēng)(修改DisplayName值)
- 在Xcode創(chuàng)建項(xiàng)目時(shí)默認(rèn)的
project.pbxproj中的所有PRODUCT_NAME = "$(TARGET_NAME)";。 - 在Xcode11.0之前如果修改
DisplayName時(shí)只是修改info.plist中的Bundle display name值,但是在Xcode11.0中修改該值則會(huì)把project.pbxproj中的一個(gè)PRODUCT_NAME改為修改后值,如果在項(xiàng)目中通過(guò)[NSBundle mainBundle] infoDictionary]取kCFBundleExecutableKey的就會(huì)有影響,并且對(duì)Build Settings中的Packaing中的一些名稱(chēng)有影響,可能還會(huì)有其他影響有待關(guān)注。
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
iOS9開(kāi)放的新API--Spotlight使用指南
作為蘋(píng)果iOS9的重要特性之一,Spotlight搜索如今重新回到主界面最左側(cè)(同樣支持主界面下滑呼出),通過(guò)API的支持,還帶來(lái)了全新的Universal Search通用搜索功能,除了網(wǎng)絡(luò)以及系統(tǒng)本身內(nèi)容之外,還能直接搜索第三方應(yīng)用內(nèi)的相關(guān)內(nèi)容。下面我們就來(lái)詳細(xì)研究下Spotlight2015-11-11
iOS開(kāi)發(fā)————詳解適配iOS10問(wèn)題
ios10已經(jīng)推出一段時(shí)間了,這篇文章主要介紹了iOS開(kāi)發(fā)————詳解適配iOS10,有興趣的可以了解一下。2016-12-12
iOS Xcode升級(jí)Xcode15報(bào)錯(cuò)SDK does not contain
這篇文章主要為大家介紹了iOS Xcode 升級(jí)Xcode15報(bào)錯(cuò): SDK does not contain 'libarclite'解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11
iOS中l(wèi)ebel特殊字符的自動(dòng)換行問(wèn)題解決
這篇文章主要給大家介紹了關(guān)于iOS中l(wèi)ebel特殊字符的實(shí)現(xiàn)不自動(dòng)換行的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)iOS具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2017-10-10
IOS AFNetworking的Post失敗及requestSerializer的正確使用
這篇文章主要介紹了IOS AFNetworking的Post失敗及requestSerializer的正確使用的相關(guān)資料,需要的朋友可以參考下2017-05-05
iOS 設(shè)置導(dǎo)航條透明效果的實(shí)例代碼
本文通過(guò)實(shí)例代碼給大家介紹了ios 設(shè)置導(dǎo)航條透明效果,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友參考下吧2018-03-03
iOS 控制器自定義動(dòng)畫(huà)跳轉(zhuǎn)方法(模態(tài)跳轉(zhuǎn))
下面小編就為大家分享一篇iOS 控制器自定義動(dòng)畫(huà)跳轉(zhuǎn)方法(模態(tài)跳轉(zhuǎn)),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-01-01

