gpt4 book ai didi

iphone - 存在导航栏和标签栏 Controller 时的 UIView 框架

转载 作者:太空狗 更新时间:2023-10-30 03:44:23 25 4
gpt4 key购买 nike

我正在 loadView 中以编程方式创建一个 UIView。该应用程序有一个 UITabBarController 和 UINavigationController。

当标签栏和导航栏同时存在时,如何创建一个自动调整大小的 View ?

我目前解决这个问题的方法是计算导航和标签栏 Controller 的高度,然后从主屏幕的高度中减去它们:

float navObjectsHeight = self.tabBarController.tabBar.frame.size.height 
+ self.navigationController.navigationBar.frame.size.height;

CGRect mainFrame = CGRectMake(0, 0, screenFrame.size.width,
screenFrame.size.height - navObjectsHeight);

UIView *contentWrapper = [[UIView alloc] initWithFrame:mainFrame];

最佳答案

UIView 有一个属性来处理这种情况。当您以编程方式创建它时,要使用的代码是:

UIView *aView = [[UIView alloc] init];
aView.autoresizingMask = UIViewAutoresizingFlexibleHeight;

关于iphone - 存在导航栏和标签栏 Controller 时的 UIView 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3687920/

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