iOS问题集、适配新特性


8、iOS16 swfit 横屏处理 UIWindowScene.requestGeometryUpdate (2022-9-21)

[Orientation] BUG IN CLIENT OF UIKIT: Setting UIDevice.orientation is not supported. Please use UIWindowScene.requestGeometryUpdate(_:)

引用:官方IPA代码: UIWindowScene.requestGeometryUpdate

//竖屏->横屏

 //iOS 16 及其以上系统运行
if #available(iOS 16, *) {
    //在视图控制器中,获取窗口场景。
    guard let windowScene = view.window?.windowScene else { return }
    //windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: .landscapeRight))
    //(同上) 请求窗口场景旋转到任何景观方向。
    windowScene.requestGeometryUpdate(.iOS(interfaceOrientations:   .landscapeRight)) { error in
      print("---requestGeometryUpdate 处理拒绝请求 \n\n")
    }
  //处理横屏View布局...
  }else{
    UIView.animate(withDuration: 0.25) {
      let value:Double = Double(UIInterfaceOrientation.landscapeRight.rawValue )
      UIDevice.current.setValue(value, forKey: "orientation")
      //处理竖屏View布局...
    }
  }


7、pod 'RealmSwift', '~> 10.15.1' 报错:

[!] The following Swift pods cannot yet be integrated as static libraries: The Swift podRealmSwiftdepends uponRealm, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may setuse_modular_headers!globally in your Podfile, or specify:modular_headers => truefor particular dependencies.

解决方案:
在podfile 中添加 use_frameworks!
然后 pod install 或 pod update


6、编译报错:CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION‘ to ‘YES‘

error: Entitlements file "cencobuy.entitlements" was modified during the build, which is not supported. You can disable this error by setting 'CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION' to 'YES', however this may cause the built product's code signature or provisioning profile to contain incorrect entitlements. (in target 'cencobuy' from project 'cencobuy')

引用:解决方案:https://blog.csdn.net/qq_17790209/article/details/113900382


5、安装证书失败

报错:Please ensure the provisioning profile is configured for this device. If not, please try to generate

解决方案:
In Xcode, 打开 Window > Devices and Simulators > Select Device > Unpair Device (for all devices) open .mobileprovision again. Good luck!


4、去除导航栏阴影
if #available(iOS 15.0, *) { //UINavigationBarAppearance属性从iOS13开始
      let navBarAppearance = UINavigationBarAppearance()
      // 背景色
      navBarAppearance.backgroundColor = UIColor.clear
      // 去掉半透明效果
      navBarAppearance.backgroundEffect = nil
      // 去除导航栏阴影(如果不设置clear,导航栏底下会有一条阴影线)
      navBarAppearance.shadowColor = UIColor.clear
      // 字体颜色
      navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
      self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
}


3、AFN的内存泄漏问题:不用单例怎么解决AFN的内存泄露呢?

解决方案:主动去给他释放

引用:https://juejin.cn/post/6844903518164221959


2、上架被禁止:"UIUserInterfaceStyle can’t be 'UIUserInterfaceStyleLight'. It can only be 'Light', 'Dark', or 'Auto
image.png

解决方案1:
提示很明显,将info.plist文件中这个属性设置为Light就好了,然后修改成Light,继续archive,继续上传。。。

在Info.plist中增加UIUserInterfaceStyle,值为Light,如下

  UIUserInterfaceStyle
  Light
image.png

解决方案2:

if (@available(iOS 13, *)) {//强制light模式
       [self.window setOverrideUserInterfaceStyle:UIUserInterfaceStyleLight];
 }


1、iOS开发-关于UI界面未能铺满全屏的问题

多半是因为Launch Screen File未处理好, 默认设置是选择Launch Screen File为LaunchScreen, 如下图:

你可能感兴趣的:(iOS问题集、适配新特性)