UITabBarController的TabBar稍微隐藏

发布于 2024-11-16 06:11:03 字数 693 浏览 2 评论 0原文

我的 UITabBarController 的 tabBar 稍微偏离视图,请告诉我我的代码有什么问题:

LoggedInViewController *lvc = [[[LoggedInViewController alloc]
                               initWithAccount:account] autorelease];
[self presentModalViewController:lvc animated:YES];

- (void)viewDidLoad
{
    self.tabController = [[UITabBarController alloc] init];
    LoggedInFeedNavigationController *navController;
    navController = [[LoggedInFeedNavigationController alloc]
                     initWithAccount:self.account];
    [self.tabController setViewControllers:
        [NSArray arrayWithObject:navController]];
    [self.view addSubview:self.tabController.view];
    [super viewDidLoad];
}

My UITabBarController's tabBar is slightly off the view, please can you tell me what is wrong with my code:

LoggedInViewController *lvc = [[[LoggedInViewController alloc]
                               initWithAccount:account] autorelease];
[self presentModalViewController:lvc animated:YES];

- (void)viewDidLoad
{
    self.tabController = [[UITabBarController alloc] init];
    LoggedInFeedNavigationController *navController;
    navController = [[LoggedInFeedNavigationController alloc]
                     initWithAccount:self.account];
    [self.tabController setViewControllers:
        [NSArray arrayWithObject:navController]];
    [self.view addSubview:self.tabController.view];
    [super viewDidLoad];
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浊酒尽余欢 2024-11-23 06:11:03

您将 tabController 视图添加为子视图,但尚未指定它应位于其父视图中的位置,或者当父视图更改大小时应如何调整其大小。尝试以下操作:

- (void)viewDidLoad
{
    [super viewDidLoad]; // see note

    self.tabController = [[UITabBarController alloc] init];
    LoggedInFeedNavigationController *navController;
    navController = [[LoggedInFeedNavigationController alloc]
                      initWithAccount:self.account];
    [self.tabController setViewControllers:
        [NSArray arrayWithObject:navController]];

    UIView *tabView = self.tabController.view;
    [self.view addSubview:tabView];

    tabView.frame = self.view.bounds;
    tabView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
                                UIViewAutoresizingFlexibleHeight);
}

注意:您不是 需要调用[super viewDidLoad],但如果您确实决定调用它,则应该在viewDidLoad 方法的开头,而不是结尾。

You are adding the tabController view as a subview, but you have not specified where it should be located within its parent view, or how it should be resized when the parent view changes size. Try the following:

- (void)viewDidLoad
{
    [super viewDidLoad]; // see note

    self.tabController = [[UITabBarController alloc] init];
    LoggedInFeedNavigationController *navController;
    navController = [[LoggedInFeedNavigationController alloc]
                      initWithAccount:self.account];
    [self.tabController setViewControllers:
        [NSArray arrayWithObject:navController]];

    UIView *tabView = self.tabController.view;
    [self.view addSubview:tabView];

    tabView.frame = self.view.bounds;
    tabView.autoresizingMask = (UIViewAutoresizingFlexibleWidth |
                                UIViewAutoresizingFlexibleHeight);
}

Note: you are not required to call [super viewDidLoad], but if you do decide to call it, you should call it at the beginning of your viewDidLoad method, and not at the end.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文