根据官网的说法,2020年4月之后所有提交到 App Store 的 iPhone 和 iPad 应用必须使用 iOS 13 以上的 SDK 进行编译,并支持 iPhone Xs Max 或 12.9 寸 iPad Pro (3代) 及以后版本的全屏幕设计。
Starting April, 2020, all iPhone and iPad apps submitted to the App Store will need to be built with the iOS 13 SDK or later. They must also support the all-screen design of iPhone XS Max or the 12.9-inch iPad Pro (3rd generation), or later.
在 iOS 13 中部分方法属性不允许使用 valueForKey、setValue:forKey: 来获取或者设置私有属性,具体表现为在运行时会直接崩溃,并提示以下崩溃信息:
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to UISearchBar's _searchField ivar is prohibited. This is an application bug'
// 崩溃 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]; 复制代码