iOS 26(iPadOS 26) 适配指南(更新中...)

5,847 阅读3分钟
  1. 不使用液态玻璃效果配置:在 info.plist 中加上
<key>UIDesignRequiresCompatibility</key>
<true/>

P.S. 该配置项会在 iOS 下个主版本中移除

  1. iPad 「Requires Full Screen」 配置项 target -> general 中不再有 Requires Full Screen 勾选项,但在 infoPlist 中可以手动添加,不清楚下个大版本中是否会被强制禁用该配置
  1. 导航条 按钮:按钮内容需居中对齐,在 iOS 26 上,按钮四周会被系统 UI 组件“圈住”,如果按钮内容不居中,UI 视觉效果会很丑。
  1. Tabbar 通过 KVC 设置 “tabbar” 属性,自定义的 tabbar 的点击事件会被系统 tabbar 拦截,可以尝试直接将自定义 tabbar 添加在系统 tabbar 上面
  1. UIScrollView 新增模糊边缘效果(UIScrollEdgeEffect 属性) topEdgeEffect、leftxxx、bottomxxx、rightxxx
  1. UIApplicationDelegate 弃用函数

     /// Tells the delegate that the application has become active
     /// - Note: This method is not called if `UIScene` lifecycle has been adopted.
    ​
    - (void)applicationDidBecomeActive:(UIApplication *)application API_DEPRECATED("Use UIScene lifecycle and sceneDidBecomeActive(_:) from UISceneDelegate or the UIApplication.didBecomeActiveNotification instead.", ios(2.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
    ​
    /// Tells the delegate that the application is about to become inactive
    /// - Note: This method is not called if `UIScene` lifecycle has been adopted.
    ​
    - (void)applicationWillResignActive:(UIApplication *)application API_DEPRECATED("Use UIScene lifecycle and sceneWillResignActive(_:) from UISceneDelegate or the UIApplication.willResignActiveNotification instead.", ios(2.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
    ​
    /// Tells the delegate that the application is now in the background
    /// - Note: This method is not called if `UIScene` lifecycle has been adopted.
    ​
    - (void)applicationDidEnterBackground:(UIApplication *)application API_AVAILABLE(ios(4.0)) API_DEPRECATED("Use UIScene lifecycle and sceneDidEnterBackground(_:) from UISceneDelegate or the UIApplication.didEnterBackgroundNotification instead.", ios(4.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
    ​
    /// Tells the delegate that the application is about to enter the foreground
    /// - Note: This method is not called if `UIScene` lifecycle has been adopted.
    ​
    - (void)applicationWillEnterForeground:(UIApplication *)application API_DEPRECATED("Use UIScene lifecycle and sceneWillEnterForeground(_:) from UISceneDelegate or the UIApplication.willEnterForegroundNotification instead.", ios(4.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
    ​
    /// Return NO if the application can't open the `url` for some reason
    ​
    - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options API_DEPRECATED("Use UIScene lifecycle and scene(_:openURLContexts:) from UISceneDelegate instead.", ios(9.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
    

    P.S. 实测,使用 Xcode 26 创建工程时,AppDelegate 类仍然默认创建,在不使用 SceneDelegate 时,以上函数仍可使用,但控制台会输出以下信息:

    `UIScene` lifecycle will soon be required. Failure to adopt will result in an assert in the future.
    

    看来,要来的迟早会来。

  1. UIwindow 弃用函数
 - (instancetype)initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER API_DEPRECATED("Use init(windowScene:) instead.", ios(2.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
 - (instancetype)init API_DEPRECATED("Use init(windowScene:) instead.", ios(2.0, 26.0), tvos(9.0, 26.0), visionos(1.0, 26.0)) API_UNAVAILABLE(watchos);
  1. iPadOS 26 如果不勾选所有的旋转方向,是不能将 App 的 window 拖拽至任意 size的。

  2. iPadOS 26 中如果设置 UIView 的 insetsLayoutMarginsFromSafeAreainsetsContentViewsToSafeArea 为 NO 时,App window 中右侧详情页面会被左侧主控制器页面遮挡(iPadOS 26 中视图层物理层级逻辑有所变化,左右不在是同级,改为左侧悬浮在内容视图上层,比如 Tabbar 也是如此),而默认的 YES 状态下,右侧详情页面的布局是从安全区布局的,所以不会出现遮挡问题。Apple 最佳实践:不要将这两个属性设为 NO!

  3. iPadOS 26 ,控制器的 view 如果添加自控制的 view,需遵循最佳实践,即 addSubview:addChildViewController: 、didMoveToParentViewController: 这三个函数,一个都不能少,否则也会出现右侧详情页被主控制器页面遮挡的问题