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中的一些名称有影响,可能还会有其他影响有待关注。

    持续更新中·····

文章若有不对地方,欢迎批评指正

iOS13中presentViewController的问题的更多相关文章

  1. 升级xcode11&ios13的坑

    Swift Packages 目前Pod跟SPM的兼容还没做好,配置好SPM后,Pod不能进行正常更新,先配置好Pod再集成SPM则没有问题 Pod以后的更新可能会解决这个问题,也会有越来越多的库支持 ...

  2. Xcode11: 删除默认Main.storyBoard, 自定义UIWindow的变化 UIWindow 不能在AppDelegate中处理

    Xcode自动新增了一个SceneDelegate文件,查找了一下官方文档WWDC2019:Optimizing App Launch 发现,iOS13中appdelegate的职责发现了改变: iO ...

  3. 在Xcode11上开发“面向低于iOS13版本的App”时的一些注意点

    相关知识: https://blog.csdn.net/BUG_delete/article/details/103699563 'AppDelegate' is only available in ...

  4. iOS - 适配 iOS 13 之工兵连扫雷

    iOS 13 支持适配的机型 目前最新 iPhone 11.iPhone 11 Pro和iPhone 11 Pro Max iPhone X.iPhone XR.iPhone XS.iPhone XS ...

  5. ios8调用相机报警告: Snapshotting a view that has not been rendered results in an empty snapshot. Ensure you(转)

    我这也报了这个警告,但按他的方法并没有起作用,把写到这个地方看是否其他人用的到 错误代码:Snapshotting a view that has not been rendered results ...

  6. iOS 唤起APP之Universal Link(通用链接)

    什么是Universal Link(通用链接) Universal Link(通用链接)是Apple在iOS9推出的一种能够方便的通过传统HTTPS链接来启动APP的功能,可以使用相同的网址打开网址和 ...

  7. [其它]iOS 13 正式版发布 iPhone 6s或更新型号均可升级

    苹果今天(2019.09.20)发布了 iOS 13 正式版,可以升级的设备包括 iPhone 6s 或更新型号.第七代 iPod Touch. iOS 13 推出深色模式,为 iPhone 带来截然 ...

  8. xcode11新项目删除main.storyboard 两种方法

    方法一 心急的童鞋按照老操作完成后再按照如下操作即可 /** 弃用storboard 1.info.plist去除 <key>UIApplicationSceneManifest</ ...

  9. Xcode11.1 踩坑备忘录

    Xcode11.1 踩坑备忘录(mac系统10.15) 1 .环信ChatDemo2.0报错 这是环信ChatDemo2.0报错 NSInteger numberOfBeforeSection = [ ...

随机推荐

  1. 一个JSP结果页面tomcat内存溢出

    如今,试验组的同事寻找新能源我看到一个奇怪的现象.一个tomcat应用,内只有一个简单的jsp页面,和这个jsp无论是什么页java代码(我想用这个jsp在她的网页测试server一对tomcat的最 ...

  2. 第一个spring boot工程

    参考. 1. 碰到的问题: -出现bind:address already in use是因为当前项目正在运行,停掉当前项目即可.cmd中命令 netstat -nao 查看所有占用的端口及PID号, ...

  3. WPF中样式和行为和触发器

    原文:WPF中样式和行为和触发器 样式简介:样式(style)是组织和重用格式化选项的重要工具,不是使用重复的标记填充XAML,以便设置外边距.内边距.颜色以及字体等细节.而是创建一系列封装所有这些细 ...

  4. 多线程Parallel和Task

    不管是Parallel还是Task,最里面都是线程池(里面是线程)当开启多个任务后,系统会根据当前的线程池的资源进行分配,任务则进行等待Parallel可以对系统的CPU进行设置,可以最大程度上榨干系 ...

  5. 【全面解禁!真正的Expression Blend实战开发技巧】十一章 全面解析布局(Grid & Canvas &StackPanel &Wrappanel)

    原文:[全面解禁!真正的Expression Blend实战开发技巧]十一章 全面解析布局(Grid & Canvas &StackPanel &Wrappanel) 写这篇文 ...

  6. 【Gerrit】自动设置reviewer

    gerrit 提供了一种代码review解决方案,但每次代码提交之后都要设置每个commit的code reviewer, 实在是痛苦. gerrit 在官方说明文档里面提供了解决方法,地址:http ...

  7. .Net 通过Cmd执行Adb命令 /c参数

    通过cmd.exe来执行adb命令,可以进行一些命令组合,直接用adb.exe的话只能执行单个adb命令 这里要注意cmd 中的/c参数,指明此参数时,他将执行整个字符串中包含的命令并退出当前cmd运 ...

  8. WPF TextBlock 文字超长截断并显示省略符号

    <TextBlock x:Name=" FontSize="9pt" Margin="0 2 0 0 " VerticalAlignment=& ...

  9. eclipse 插件编写(三)

    参考:http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Fguide%2Fworkbench_ ...

  10. Linux目录结构及文件操作

    Linux文件目录遵循FHS标准 绝对路径:从根目录开始的路径:相对目录:从当前路径开始的路径 .表示当前目录,..表示上级目录,~表示当前用户的home目录,pwd获得当前绝对路径 新建文件 tou ...