公式ウェブサイトによると、2020年4月以降にApp Storeに提出されるすべてのiPhoneおよびiPadアプリケーションは、iOS 13以降のSDKでコンパイルされ、フルスクリーンのiPhone XsMaxまたは12.9インチiPadPro(第3世代)以降のバージョンをサポートする必要があります。設計。
2020年4月以降、App Storeに提出されるすべてのiPhoneおよびiPadアプリは、iOS 13SDK以降でビルドする必要があります。また、iPhone XSMaxまたは12.9インチiPadPro(第3世代)以降の全画面デザインもサポートしている必要があります。
1.プライベートメソッドKVCはクラッシュを引き起こす可能性があります
iOS 13では、一部のメソッドプロパティで プライベートプロパティの使用valueForKey
、setValue:forKey:
取得、設定が許可されていません 。具体的な兆候は、実行時に直接クラッシュし、次のクラッシュ情報を表示することです。
***キャッチされなかった例外 'NSGenericException'が原因でアプリを終了しています。理由: 'UISearchBarの_searchFieldivarへのアクセスは禁止されています。これはアプリケーションのバグです」
// 崩溃 api
UITextField *textField = [searchBar valueForKey:@"_searchField"];
// 替代方案 1,使用 iOS 13 的新属性 searchTextField
searchBar.searchTextField.placeholder = @"search";
// 替代方案 2,遍历获取指定类型的属性
- (UIView *)findViewWithClassName:(NSString *)className inView:(UIView *)view{
Class specificView = NSClassFromString(className);
if ([view isKindOfClass:specificView]) {
return view;
}
if (view.subviews.count > 0) {
for (UIView *subView in view.subviews) {
UIView *targetView = [self findViewWithClassName:className inView:subView];
if (targetView != nil) {
return targetView;
}
}
}
return nil;
}
// 调用方法
UITextField *textField = [self findViewWithClassName:@"UITextField" inView:_searchBar];
复制代码
// 崩溃 api
[searchBar setValue:@"取消" forKey:@"_cancelButtonText"];
// 替代方案,用同上的方法找到子类中 UIButton 类型的属性,然后设置其标题
UIButton *cancelButton = [self findViewWithClassName:NSStringFromClass([UIButton class]) inView:searchBar];
[cancelButton setTitle:@"取消" forState:UIControlStateNormal];
复制代码
// 崩溃 api。获取 _placeholderLabel 不会崩溃,但是获取 _placeholderLabel 里的属性就会
[textField setValue:[UIColor blueColor] forKeyPath:@"_placeholderLabel.textColor"];
[textField setValue:[UIFont systemFontOfSize:20] forKeyPath:@"_placeholderLabel.font"];
// 替代方案 1,去掉下划线,访问 placeholderLabel
[textField setValue:[UIColor blueColor] forKeyPath:@"placeholderLabel.textColor"];
[textField setValue:[UIFont systemFontOfSize:20] forKeyPath:@"placeholderLabel.font"];
// 替代方案 2
textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"输入" attributes:@{
NSForegroundColorAttributeName: [UIColor blueColor],
NSFontAttributeName: [UIFont systemFontOfSize:20]
}];
复制代码