美文网首页
Xcode11 iOS13问题汇总

Xcode11 iOS13问题汇总

作者: 冰天无幻 | 来源:发表于2019-11-06 15:13 被阅读0次

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

本文链接:https://blog.csdn.net/bitcser/article/details/100113549

问题一:报错 Multiple methods named 'numberOfItemsInSection:' found with mismatched result, parameter type or attributes

这个问题是由于二维数组取值时,编译器不知道是什么对象,调用对象的方法会报错,在Xcode之前的版本没有问题,解决方法是,告诉编译器是什么类型,我的是UICollectionView类型,如下:

解决前:

NSInteger numberOfBeforeSection = [_update[@"oldModel"] numberOfItemsInSection:updateItem.indexPathBeforeUpdate.section];

解决后:

NSInteger numberOfBeforeSection = [(UICollectionView *)_update[@"oldModel"] numberOfItemsInSection:updateItem.indexPathBeforeUpdate.section];

问题二:夜间模式,大致是把没有设置背景色的系统控件会被设置成黑色,一些控件是tintColor没设置的话也会被改。

如下方式可以避免页面被改动,将来如果有设计夜间模式的话,再进行处理

配置方式有两种,单页面配置 和 全局配置。

    单页配置

    将需要配置的 UIViewControler 对象的 overrideUserInterfaceStyle 属性设置成 UIUserInterfaceStyleLight 或者 UIUserInterfaceStyleDark 以强制是某个页面显示为 浅/深色模式

    全局配置

    在工程的Info.plist的中,增加/修改 UIUserInterfaceStyle为UIUserInterfaceStyleLight或UIUserInterfaceStyleDark

问题三:UISearchBar 的页面crash

因为这一句代码:UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];

Xcode 11 应该是做了限制访问私有属性的一些处理。然后增加了searchTextField属性,但是是只读的,不能设置属性,所以还得通过遍历子view获取到,改动如下:

NSString *version = [UIDevice currentDevice].systemVersion;

      if (version.doubleValue >= 13.0) {

          // 针对 13.0 以上的iOS系统进行处理

          UITextField *searchField;

          NSUInteger numViews = [self.searchBar.subviews count];

          for(int i = 0; i < numViews; i++) {

            if([[self.searchBar.subviews objectAtIndex:i] isKindOfClass:[UITextField class]]) {

                searchField = [self.searchBar.subviews objectAtIndex:i];

            }

          }

          if (searchField) {

            //这里设置相关属性

          }else{}

      } else {

          // 针对 13.0 以下的iOS系统进行处理

          UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];

            if(searchField) {

                //这里设置相关属性

            }else{}

      }

问题四:present到登录页面时,发现新页面不能顶到顶部,更像是Sheet样式,如下图:

原因是iOS 13 多了一个新的枚举类型 UIModalPresentationAutomatic,并且是modalPresentationStyle的默认值。

UIModalPresentationAutomatic实际是表现是在 iOS 13的设备上被映射成UIModalPresentationPageSheet。

但是需要注意一点PageSheet 与 FullScreen 生命周期并不相同

FullScreen会走完整的生命周期,PageSheet因为父视图并没有完全消失,所以viewWillDisappear及viewWillAppear并不会走,如果这些方法里有一些处理,还是换个方式,或者用FullScreen

设置方法:

    CILoginVC *vc = [[CILoginVC alloc] init];

    vc.modalPresentationStyle = UIModalPresentationFullScreen;

    [self presentViewController:vc animated:YES completion:nil];

————————————————

版权声明:本文为CSDN博主「李永吉」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。

原文链接:https://blog.csdn.net/bitcser/article/details/100113549

相关文章

网友评论

      本文标题:Xcode11 iOS13问题汇总

      本文链接:https://www.haomeiwen.com/subject/bdmubctx.html