• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ios - UINavigationBar 调整大小并覆盖 UIViews

[复制链接]
菜鸟教程小白 发表于 2022-12-12 22:44:26 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我们从 Storyboard 中实例化一个 UINavigationController 和一个 UIViewController,如下所示:

UIStoryboard *sb = [UIStoryboard storyboardWithName"AddOrder" bundle:nil];
UIViewController *vc = [sb instantiateInitialViewController];
UIViewController *topVC = ((UINavigationController *) vc).topViewController;

vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];

enter image description here

从这里看,UIViewController 似乎没有占据整个 UIWindow,它看起来像在 ios6 上一样下降了 20 分。如果仔细观察,您甚至可以在左上角看到底层 UISplitViewController 的分隔线。

问题是,当用户在 UIViewController 上的 UITableView 上点击一个选项时,我们调用 [self performSegueWithIdentifier: sender:]推送一个新的 UIViewController,但是当他们旋转它时,它看起来像这样:

enter image description here

至少可以说有点局促。 但是现在,当我们回到第一个 UIViewController 并旋转时,我们得到了这个:

enter image description here

问题是,现在已经覆盖了搜索栏。你会注意到你也看不到底层的 UISplitViewController 了。如您所见,现在 UINavigationBar 似乎覆盖了其他 20 pts,并且高度更大。

我通过调用 self.edgesForExtendedLayout = UIRectEdgeNone; 来“解决”了这个问题,但这只是将 UIView 推得很远。我还玩弄了添加 [UIViewController attemptRotationToDeviceOrientation] 但什么也没有。在 Apple 的 HIG 中,它指出导航栏不应该改变它在 iPad 上的高度,但是当我退出框架时,这发生在我身上。

有什么想法吗?



Best Answer-推荐答案


您好,您可以使用这些属性创建 View Controller enter image description here

并在应用程序窗口上添加模态

[self.view.window.rootViewController presentViewController:vc animated:YES completion:nil];

我认为您的问题将由此解决。

关于ios - UINavigationBar 调整大小并覆盖 UIViews,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24070281/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap