gpt4 book ai didi

iPhone 纵向导航栏高度仍然较短

转载 作者:行者123 更新时间:2023-12-03 18:54:52 26 4
gpt4 key购买 nike

我的应用程序的 Root View Controller 支持任何方向,但用户可以导航到另一个仅支持横向方向的 View Controller 。

基本问题是,无论设备的实际物理方向如何,当用户弹回 Root View Controller 时,导航栏的高度都适合横向模式。我想弄清楚如何让导航栏以 44(纵向高度)而不是 32(横向高度)的高度显示。

虽然导航栏未设置为正确的高度,但 Root View Controller 的 UITableView 已正确偏移(距屏幕顶部 44 像素)。

在第二个 View Controller 的 -viewWillAppear 内:我执行标准旋转变换:

if (deviceOrientation == UIDeviceOrientationPortrait)
{
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenHeight, screenWidth);
navView.transform = CGAffineTransformIdentity;
navView.transform = CGAffineTransformMakeRotation(degreesToRadians(90));
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
}

因为这个辅助 View Controller 允许导航到从属 View Controller (以及弹出回 Root View Controller ),所以我将以下内容添加到 -viewWillDisappear:

if (deviceOrientation == UIDeviceOrientationPortrait)
{
UIScreen *screen = [UIScreen mainScreen];
CGFloat screenWidth = screen.bounds.size.width;
CGFloat screenHeight = screen.bounds.size.height;
UIView *navView = [[self navigationController] view];
navView.bounds = CGRectMake(0, 0, screenWidth, screenHeight);
navView.transform = CGAffineTransformIdentity;
navView.center = CGPointMake(screenWidth/2.0, screenHeight/2.0);
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
}

感谢您提供有关如何强制重新计算导航栏高度的建议。

最佳答案

不确定是否有更好的方法,但这有效:

[[self navigationController] setNavigationBarHidden:YES animated:NO];
[[self navigationController] popViewControllerAnimated:YES];
[[self navigationController] setNavigationBarHidden:NO animated:NO];

基本上,隐藏导航栏,弹出 View Controller 并显示导航栏。某处的一些代码调整了导航栏的高度,一切都很好。

关于iPhone 纵向导航栏高度仍然较短,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3339843/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com