iOS 13 适配

本文详细介绍了Xcode11beta下载资源及iOS13开发中需注意的问题,包括私有KVC的正确使用方法、暗黑模式适配技巧、MPRemoteCommandCenter的使用规范、模态弹出交互变化以及微博分享兼容性解决方案。

Xcode 11 beta 下载地址
WWDC 2019 视频

私有KVC

不能随意的通过 KVC 来修改一些没有暴露出来的属性了,比如valueForKeysetValue: forKey获取和设置私有属性,需要使用其它方式修改。

*** Terminating app due to uncaught exception 'NSGenericException', reason: 'Access to xxx's _xxx ivar is prohibited. This is an application bug'

 如: 

[self setValue:color forKeyPath:@"_placeholderLabel.textColor"];
//替换为
self.attributedPlaceholder = [[NSAttributedString alloc] initWithString:self.placeholder attributes:@{NSForegroundColorAttributeName: color}];

暗黑模式

If you make appearance-sensitive changes outside of these methods, your app may not draw its content correctly for the current environment. The solution is to move your code into these methods. For example, instead of setting the background color of an NSView object's layer at creation time, move that code to your view’s updateLayer() method instead, as shown in the code example below. Setting the background color at creation time might seem appropriate, but because CGColor objects do not adapt, setting it at creation time leaves the view with a fixed background color that never changes. Moving your code to updateLayer() refreshes that background color whenever the environment changes.
override func updateLayer() {
   self.layer?.backgroundColor = NSColor.textBackgroundColor.cgColor

   // Other updates.
}

暗黑模式适配参考 :https://blog.csdn.net/weixin_33817333/article/details/91401519
Web Content适配  :https://blog.csdn.net/u012413955/article/details/92198556

MPRemoteCommandCenter

addTarget:action:在iOS 13中selector 一定要返回MPRemoteCommandHandlerStatus,要不然会闪退。

// Your selector should return a MPRemoteCommandHandlerStatus value when
// possible. This allows the system to respond appropriately to commands that
// may not have been able to be executed in accordance with the application's
// current state.
- (void)addTarget:(id)target action:(SEL)action;

模态弹出默认交互改变

iOS 13 的 presentViewController 默认有视差效果,模态出来的界面现在默认都下滑返回。 一些页面必须要点确认才能消失的,需要适配。如果项目中页面高度全部是屏幕尺寸,那么多出来的导航高度会出现问题。
// Swift self.modalPresentationStyle = .fullScreen
// Objective-C self.modalPresentationStyle = UIModalPresentationFullScreen;

/*
 Defines the presentation style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter.
 If this property has been set to UIModalPresentationAutomatic, reading it will always return a concrete presentation style. By default UIViewController resolves UIModalPresentationAutomatic to UIModalPresentationPageSheet, but system-provided subclasses may resolve UIModalPresentationAutomatic to other concrete presentation styles. Participation in the resolution of UIModalPresentationAutomatic is reserved for system-provided view controllers.
 Defaults to UIModalPresentationAutomatic on iOS starting in iOS 13.0, and UIModalPresentationFullScreen on previous versions. Defaults to UIModalPresentationFullScreen on all other platforms.
 */
@property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle API_AVAILABLE(ios(3.2));

微博分享闪退

微博SDK官网已更新兼容iOS13,升级即可。

其他参考:

https://juejin.im/post/5d00af64e51d455d88219ee2

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值