代码之家  ›  专栏  ›  技术社区  ›  Bryan

UITabarController视图位置和大小

  •  1
  • Bryan  · 技术社区  · 15 年前

    我有一个UITabbarController,它添加了一个视图控制器,但是定位是关闭的。屏幕顶部有一个20px的间隙,加载的视图控制器的底部被隐藏。如何移动调整加载的视图控制器的大小?

    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查看窗口大小和位置。

    3 回复  |  直到 10 年前
        1
  •  5
  •   Bryan    15 年前

    我最终手工创建了frame rect:

    tabBarController.view.frame = CGRectMake(0,0,320,460);
    
        2
  •  1
  •   h4xxr    15 年前

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

    我建议您打开flashcardview controller.xib文件,并再次检查“模拟界面元素”下的视图,在“状态栏”中没有选择任何内容。然后将视图上移20像素。

        3
  •  1
  •   MD SHAHIDUL ISLAM    10 年前
    CGRect screenArea = [[UIScreen mainScreen] applicationFrame];
    
    tabBarController.view.frame = CGRectMake(0,0,screenArea.size.width,screenArea.size.height);