国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > iOS > 正文

iOS13 適配和Xcode11.0踩坑小結

2020-07-26 02:18:42
字體:
來源:轉載
供稿:網友

iOS13中presentViewController的問題

更新了Xcode11.0 beta之后,在iOS13中運行代碼發現presentViewController和之前彈出的樣式不一樣。

會出現這種情況是主要是因為我們之前對UIViewController里面的一個屬性,即modalPresentationStyle(該屬性是控制器在模態視圖時將要使用的樣式)沒有設置需要的類型。在iOS13中modalPresentationStyle的默認改為UIModalPresentationAutomatic,而在之前默認是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));

要改會原來模態視圖樣式,我們只需要把UIModalPresentationStyle設置為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運行項目時突然APP就crash掉了。定位到的問題是在設置UITextFieldPlaceholder也就是占位文本的顏色和字體時使用了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]}];

并且只需要在初始化的時候設置attributedPlaceholder即富文本的占位文本,再重新賦值依然使用placeolder直接設置文本內容,樣式不會改變。(想要這種效果的話需要在初始化attributedPlaceholder時的字符串不為空)

Universal Link(通用鏈接)

在Xcode11中配置Universal Link(通用鏈接)步驟:

在iOS13之前在其他APP去safari中打開Universal Link(通用鏈接)系統匹配域名是全匹配,而在iOS13之后規則發生了變化,猜測是包含關系。比如在iOS13之前,如果Universal Link(通用鏈接)為w.mydomain.com那么在微信或者其他APP訪問www.mydomain.com然后點擊去safari打開則不會拉起相應APP,而在iOS13則會拉起相應APP。
而在safari中輸入的鏈接則依然和iOS之前一樣,只有www.mydomain.com才會提示打開相應APP。

修改APP名稱(修改DisplayName值)

  • 在Xcode創建項目時默認的project.pbxproj中的所有PRODUCT_NAME = "$(TARGET_NAME)";。
  • 在Xcode11.0之前如果修改DisplayName時只是修改info.plist中的Bundle display name值,但是在Xcode11.0中修改該值則會把project.pbxproj中的一個PRODUCT_NAME改為修改后值,如果在項目中通過[NSBundle mainBundle] infoDictionary]kCFBundleExecutableKey的就會有影響,并且對Build Settings中的Packaing中的一些名稱有影響,可能還會有其他影響有待關注。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 开化县| 轮台县| 曲沃县| 弥渡县| 彰武县| 深州市| 阳新县| 平江县| 永年县| 永寿县| 仪陇县| 桓台县| 永清县| 罗源县| 奈曼旗| 江达县| 清丰县| 同江市| 濮阳县| 会泽县| 银川市| 宝鸡市| 麦盖提县| 金坛市| 桂平市| 伊川县| 卢湾区| 涞水县| 神池县| 望江县| 东港市| 丹巴县| 海城市| 荆门市| 沾益县| 南安市| 新和县| 西宁市| 济源市| 凉城县| 资源县|