【问题标题】:UITabBarController View Position and SizeUITabBarController 视图位置和大小
【发布时间】:2009-08-24 23:22:12
【问题描述】:

我有一个添加 viewController 的 UITabBarController,但定位已关闭。屏幕顶部有大约 20px 的间隙,加载的 viewController 的底部是隐藏的。如何移动调整加载的 viewController 的大小?

viewController = [[FlashCardViewController alloc] initWithNibName:@"FlashCardViewController" bundle:[NSBundle mainBundle]];
viewController.view.bounds = [[UIScreen mainScreen]bounds];
//viewController.view.alpha = 0.0;
//[self.view addSubview:viewController.view];

tabBarController = [[UITabBarController alloc] initWithNibName:nil bundle:nil];
tabBarController.viewControllers = [NSArray arrayWithObject:viewController];
tabBarController.view.alpha = 0.0;
[self.view addSubview:tabBarController.view];

我尝试了这两种方法,但都没有运气。

tabBarController.view.bounds = [[UIScreen mainScreen] bounds];
tabBarController.view.frame = [[UIScreen mainScreen] bounds];

无论如何,这并不是我真正想要做的。我想将它们设置为 tabBarController 查看窗口的大小和位置。

【问题讨论】:

    标签: iphone cocoa-touch uiviewcontroller uitabbarcontroller bounds


    【解决方案1】:

    我最终手动创建了框架矩形:

    tabBarController.view.frame = CGRectMake(0,0,320,460);
    

    【讨论】:

    • 感谢您的提示。我可以通过在 viewWillAppear 方法中使用 self.tabBarController.view.frame = [[self view] frame] 来快速计算出这段代码的数字。
    【解决方案2】:

    20 像素听起来很像状态栏的高度。

    我建议您打开 FlashCardViewController.xib 文件并仔细检查“模拟界面元素”下的视图是否在“状态栏”中没有选择任何内容。然后应该将您的视图向上移动 20 像素。

    【讨论】:

    • 我做了你建议的改变,好主意,但它对我的显示没有任何影响。我认为问题与 tabBarController 有关。可能有 75% 的标签栏在底部被截断。
    【解决方案3】:
    CGRect screenArea = [[UIScreen mainScreen] applicationFrame];
    
    tabBarController.view.frame = CGRectMake(0,0,screenArea.size.width,screenArea.size.height);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-10-19
      • 1970-01-01
      • 2012-08-08
      • 1970-01-01
      • 1970-01-01
      • 2017-08-29
      • 1970-01-01
      相关资源
      最近更新 更多