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 及其以上系統(tǒng)運(yùn)行
if #available(iOS 16, *) {
    //在視圖控制器中,獲取窗口場景。
    guard let windowScene = view.window?.windowScene else { return }
    //windowScene.requestGeometryUpdate(.iOS(interfaceOrientations: .landscapeRight))
    //(同上) 請求窗口場景旋轉(zhuǎn)到任何景觀方向。
    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、去除導(dǎo)航欄陰影
if #available(iOS 15.0, *) { //UINavigationBarAppearance屬性從iOS13開始
      let navBarAppearance = UINavigationBarAppearance()
      // 背景色
      navBarAppearance.backgroundColor = UIColor.clear
      // 去掉半透明效果
      navBarAppearance.backgroundEffect = nil
      // 去除導(dǎo)航欄陰影(如果不設(shè)置clear,導(dǎo)航欄底下會有一條陰影線)
      navBarAppearance.shadowColor = UIColor.clear
      // 字體顏色
      navBarAppearance.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
      self.navigationController?.navigationBar.scrollEdgeAppearance = navBarAppearance
}


3、AFN的內(nèi)存泄漏問題:不用單例怎么解決AFN的內(nèi)存泄露呢?

解決方案:主動去給他釋放

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


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

解決方案1:
提示很明顯,將info.plist文件中這個屬性設(shè)置為Light就好了,然后修改成Light,繼續(xù)archive,繼續(xù)上傳。。。

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

  <key>UIUserInterfaceStyle</key>
  <string>Light</string>
image.png

解決方案2:

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


1、iOS開發(fā)-關(guān)于UI界面未能鋪滿全屏的問題

多半是因?yàn)長aunch Screen File未處理好, 默認(rèn)設(shè)置是選擇Launch Screen File為LaunchScreen, 如下圖:

QQ20210818-155334@2x.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容