1、横竖切换

[UIDevice currentDevice] 使用setValue:forKey:的方式iOS16上面已经不可用,继而要使用UIWindowScene里面函数请求

if (@available(iOS 16.0, *)) {
    UIWindowScene *windowScene = (UIWindowScene *)[[[UIApplication sharedApplication] connectedScenes] allObjects].firstObject;
    UIWindowSceneGeometryPreferencesIOS *perference = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
    perference.interfaceOrientations = 1 << deviceOrientation;
    [windowScene requestGeometryUpdateWithPreferences:perference errorHandler:^(NSError * _Nonnull error) {
        NSLog(@"error--%@", error);
    }];
} else {
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:deviceOrientation] forKey:@"orientation"];
        [UIViewController attemptRotationToDeviceOrientation];
}


复制代码

1.1、屏幕旋转通知在iOS16无法处触发

需要重写UIViewController的viewWillTransitionToSize:withTransitionCoordinator:,在此函数里面处理UI。

1.2、iOS16 使用过YYTextView之后无法旋转屏幕

使用过UITextView之后,再调用函数 requestGeometryUpdateWithPreferences:geometryPreferences errorHandler: 请求无效,无法旋转屏幕

分析打印所有的connectedScenes

使用YYTextView之前

使用YYTextView之后

问题当前的UIWindowScene里面多了一层YYTextView添加YYTextEffectWindow去掉这一层window可以了。

2、xcode14 UIViewController在dealloc时发生崩溃

iOS16调试时候报错

Application circumvented objective-c runtime dealloc initiation for <%s&gt; object崩溃

原因是: IOS16 苹果不允许重写系统控件分类(Categroy)中重写 + (void)initialize方法

3、使用xcode14打出来的包,在iOS12.2以下的系统发生崩溃

使用otool工具查看二进制文件发现

二进制里面多了一个 /usr/lib/swift/libswiftCoreGraphics.dylib (compatibility version 1.0.0, current version 120.100.0)

解决方法

Build Phases -> Link Binary With Librarires 里面添加libswiftCoreGraphics.tbd

Apple Recommended(苹果推荐的解决方法)

xcode14 解决方法

Build Setting -> other link flags 添加 -Wl,-weak-lswiftCoreGraphics
复制代码

4、如果UINavigationItemtitleView有自动布局,UI布局展示错误

extension UINavigationItem {
    func addView(_ view: UIView, _ color: UIColor = .clear) {
        if #available(iOS 13, *) {
            let tempTitleV = UIView()
            tempTitleV.backgroundColor = color
            tempTitleV.frame = CGRect(x: 0, y: 0, width: App.screenWidth - 100, height: App.navigationBarHeight)
            self.titleView = tempTitleV
            tempTitleV.addSubview(view)
            view.snp.makeConstraints { make in
                make.center.equalToSuperview()
                make.height.equalTo(App.navigationBarHeight)
                make.width.equalTo(App.screenWidth - 100)
            }
        } else {
            self.titleView = view
        }
    }
}

相关链接:Apple Forums 链接

原文地址:https://blog.csdn.net/Arodung/article/details/127443184

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_28702.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注