1、UIViewController切换方式modalPresentationStyle
iOS13默认UIModalPresentationAutomatic模式,需要改模式要用UIModalPresentationFullScreen。
vc.modalPresentationStyle = UIModalPresentationFullScreen;
但问题是项目里vc太多,viewController并没有一个相同父VC,全局改太费劲了。
所以:
在appDelegate中实现了ViewController的分类,改变了modalPresentationStyle的值完美解决。
//iOS 13 的 presentViewController 默认有视差效果,模态出来的界面现在默认都下滑返回。一些页面必须要点确认才能消失的,需要适配。如果项目中页面高度全部是屏幕尺寸,那么多出来的导航高度会出现问题。
@implementation UIViewController(modalPresentationStyle)
- (UIModalPresentationStyle)modalPresentationStyle{
return UIModalPresentationFullScreen;
}
@end
2、"NSGenericException" - reason: "Access to UITextField's _placeholderLabel ivar is prohibited. This is an application bug"
设置TextFiled的默认文字颜色在iOS13 Crash。
[textfield setValue:[UIColor whiteColor] forKeyPath:@"_placeholderLabel.textColor"];
解决:
导入头文件:
#import <objc/runtime.h>
Ivar ivar = class_getInstanceVariable([UITextField class], "_placeholderLabel");
UILabel *placeholderLabel = object_getIvar(textField, ivar);
placeholderLabel.textColor = [UIColor whiteColor];
3. UITableViewCell的UITableViewCellAccessoryDisclosureIndicator 显示不正常
解决问题:
cell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed: @"img_deviceInfo_arrow"]];