Xcode11 iOS13 problem summary

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

This problem is due to the fact that the compiler does not know what the object is when the value of the two-dimensional array is taken. The method of calling the object will report an error. There is no problem in the previous version of Xcode. The solution is to tell the compiler what type, mine is the UICollectionView type ,as follows:

Before solving:

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

After solving:

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

Question 2: Night mode, roughly means that the system controls that have not set the background color will be set to black, and some controls will be changed if the tintColor is not set.

The following methods can prevent the page from being changed, and if there is a night mode design in the future, then proceed

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

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

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

Question three:UISearchBar 的页面crash

Because of this code: UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];

Xcode 11 should have done some processing to restrict access to private properties. Then the searchTextField属性,但是是只读的,不能设置属性,所以还得通过遍历子viewacquisition is added , and the changes are as follows:

NSString *version = [UIDevice currentDevice].systemVersion;
      if ([version floatValue] >= 13.0) {
            UITextField *textField = self.searchBar.searchTextField;
            textField.backgroundColor = [UIColor whiteColor];
            textField.textColor= CIDarkGrayTextColor;
            textField.font= [UIFont systemFontOfSize:14];
         

      } else {
          // 针对 13.0 以下的iOS系统进行处理
          UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];
             
             if(searchField) {
                //这里设置相关属性
                 
             }else{}
      }

Get the cancleButton of SearchBar

if ([[[UIDevice currentDevice]systemVersion] floatValue] >= 13.0) {
  for(id cc in [self.searchBar subviews]) {
    for (id zz in [cc subviews]) {
      for (id gg in [zz subviews]) {
        if([gg isKindOfClass:[UIButton class]]){
          UIButton *cancelButton = (UIButton *)gg;
          [cancelButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
        }
      }
    }
  }
}else{
  UIButton*cancelButton = (UIButton *)[self.searchBar getVarWithName:@"_cancelButton"];
  [cancelButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
}

 

Question 4: When presenting to the login page, I found that the new page cannot be topped, which is more like the Sheet样式,following picture:

The reason is that iOS 13 has a new enumeration type UIModalPresentationAutomatic, and it is modalPresentationStylethe default value.

UIModalPresentationAutomaticThe actual performance is mapped to iOS 13 devices UIModalPresentationPageSheet.

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

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

Setting method:

    CILoginVC *vc = [[CILoginVC alloc] init];
    vc.modalPresentationStyle = UIModalPresentationFullScreen;
    [self presentViewController:vc animated:YES completion:nil];

 

Pay attention to the IT aesthetics public account and share more knowledge

Guess you like

Origin blog.csdn.net/bitcser/article/details/100113549