You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

适配iOS 26时iPad端导航项组内三点按钮窗口调整后位置异常求助

适配iOS 26时iPad端导航项组内三点按钮窗口调整后位置异常求助

我正在维护一个老的Objective-C项目,现在需要适配iOS 26和Liquid Glass,把UI调整到当前系统的规范。目前在iPad上运行时遇到了一个导航栏的问题:调整窗口大小后,导航栏中多按钮折叠生成的三点按钮不会自动归位到对应的导航项组里,反而会直接显示在左侧导航按钮的上方,布局完全错乱。

我已经尝试过的操作

  • 给项目的Info.plist添加了Application Scene Manifest配置,适配多场景模式
  • 新建了SceneDelegate,通过UIWindowScene初始化窗口,并且将窗口实例传递给原有的AppDelegate调用初始化逻辑:
    class SceneDelegate: UIResponder, UIWindowSceneDelegate {
        var window: UIWindow?
        let appDelegate = UIApplication.shared.delegate as! AppDelegate
        
        func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
            guard let scene = (scene as? UIWindowScene) else { return }
            window = UIWindow(windowScene: scene)
            window?.isHidden = false
            appDelegate.window = window
            appDelegate.initWithWindow()
        }
    }
    
    // AppDelegate.m 中的初始化方法
    - (void)initWithWindow {
        ...
        [self initViewControllers];
        NSArray *tabArray = [self getTabArray];
        self.mainTabVC = [[MainTabBarViewController alloc] init:tabArray];
        self.window.rootViewController = self.mainTabVC;
        [self.window setHidden:false];
        ...
    }
    
  • 后续我把所有初始化逻辑都迁移到了SceneDelegate中,现在AppDelegate基本不再处理任何业务逻辑
  • 导航控制器的创建方式如下:
    BookmarksTabViewController *bookmark = [[BookmarksTabViewController alloc] initWithNibName:@"BookmarksTabViewController" bundle:nil];
    self.bookmarkNavigationController = [[UINavigationController alloc] initWithRootViewController:bookmark];
    
  • 左侧导航按钮的添加代码:
    self.clearAllBarButton = [[UIBarButtonItem alloc] initWithTitle:@"C" style:UIBarButtonItemStylePlain target:self action:@selector(clearAllButtonPressed)];
    self.clearAllBarButton.tintColor = [UIColor redColor];
    self.navigationItem.leftBarButtonItems = @[self.clearAllBarButton];
    
  • 更新到iOS 26和Xcode Beta 4后,三点按钮不再和左侧导航项重叠了,但显示效果还是和正常的原生App不一样,不符合系统默认的布局规范

我的需求

希望调整iPad窗口大小时,导航栏的折叠三点按钮能像原生App一样自动正确归位到对应的导航项组内,完全遵循系统的导航栏布局逻辑。

内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.07 13:29:50