ios – UITabBarController – Child(Tab)ViewControllers的不正确和不一致的边界

ios – UITabBarController – Child(Tab)ViewControllers的不正确和不一致的边界,第1张

概述我有一个带有两个选项卡的UITabBarController.每个选项卡都是UITableViewController. 当UITabBarController出现时,两个选项卡视图都有不正确边界.第一个选项卡正确位于导航栏下方,但延伸到底部的选项卡栏下方.第二个选项卡是另一种方式,从导航栏下方开始,但在底部的选项卡栏之前正确停止. 我正在创建和呈现TabBarController,如下所示: 我有一个带有两个选项卡的UITabbarController.每个选项卡都是UItableVIEwController.

当UITabbarController出现时,两个选项卡视图都有不正确的边界.第一个选项卡正确位于导航栏下方,但延伸到底部的选项卡栏下方.第二个选项卡是另一种方式,从导航栏下方开始,但在底部的选项卡栏之前正确停止.

我正在创建和呈现TabbarController,如下所示:

ActiveListTabbarVIEwController* ListTabbarController = [[ActiveListTabbarVIEwController alloc] initWithListController:_ListController];UINavigationController* nc = [[UINavigationController alloc] initWithRootVIEwController:ListTabbarController];[self presentVIEwController:nc animated:YES completion:^(){}];

然后在TabbarController的init中,创建并添加子(tab)视图,如下所示:

_todoListVIEwController = [[BasictableVIEwController alloc] initWithList:[_controller itemsTodo]];_todoListVIEwController.delegate = self;_todoListVIEwController.Title = @"To Do";_completedListVIEwController = [[BasictableVIEwController alloc] initWithList:[_controller itemsDone]];_completedListVIEwController.delegate = self;_completedListVIEwController.Title = @"Completed";[self setVIEwControllers:@[_todoListVIEwController,_completedListVIEwController]];

我究竟做错了什么?

谢谢,
加文

更新:根据建议将以下方法添加到BasictableVIEwController:

- (UIRectEdge)edgesForExtendedLayout{    return UIRectEdgeNone;}

第一个选项卡的行为已得到改进并且位置正确,但第二个选项卡保持不变.情况如下:

有什么建议?
干杯.

解决方法 问题是由我呈现UITabbarController的方式引起的
ActiveListTabbarVIEwController* ListTabbarController = [[ActiveListTabbarVIEwController alloc] initWithListController:_ListController];UINavigationController* nc = [[UINavigationController alloc] initWithRootVIEwController:ListTabbarController];[self presentVIEwController:nc animated:YES completion:^(){}];

回到Apple的文档,我不确定这是否是呈现UITabbarController的有效方式.也就是说,将其呈现为另一个视图控制器的子节点.

不是.以下是为我确认的一些片段;从这一点,以及由此产生的变化,我认为在我上面提供一个TabbarController是不正确的.

从:
https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/TabBarControllers.html

Before creating a tab bar interface,you need to decIDe how you intend
to use a tab bar interface. Because it imposes an overarching
organization on your data,you should use one only in these specific
ways:

Install it directly as a window’s root vIEw controller. Install it as one of the two vIEw controllers in a split vIEw interface. (iPad only) Present it modally from another vIEw controller. display it from a popover. (iPad only)

从:
https://developer.apple.com/library/ios/documentation/uikit/reference/UITabBarController_Class/Reference/Reference.html

Unlike other vIEw controllers,a tab bar interface should never be
installed as a child of another vIEw controller.

并进一步澄清:

A tab bar controller is a container vIEw controller that you use to
divIDe your app into two or more distinct modes of operation.

A navigation controller presents data that is organized hIErarchically
and is an instance of the UINavigationController class. The methods of
this class provIDe support for managing a stack-based collection of
content vIEw controllers.

我将UITabbarController作为导航控制器的根视图呈现的原因是我想要导航栏…

这就是我现在在TabbarController的init中实现的目标:

- (ID)initWithListController:(BasicListController *)controller{    self = [super init];    if (self) {        _controller = controller;        _todoListVIEwController = [[BasictableVIEwController alloc] initWithList:[_controller itemsTodo]];        _todoListVIEwController.delegate = self;        _todoListVIEwController.Title = @"To Do";        _completedListVIEwController = [[BasictableVIEwController alloc] initWithList:[_controller itemsDone]];        _completedListVIEwController.delegate = self;        _completedListVIEwController.Title = @"Completed";        UINavigationController* ncTodo = [[UINavigationController alloc] initWithRootVIEwController:_todoListVIEwController];        UINavigationController* ncCompleted = [[UINavigationController alloc] initWithRootVIEwController:_completedListVIEwController];        [self setVIEwControllers:@[ncTodo,ncCompleted]];        UIbarbuttonItem* donebutton = [[UIbarbuttonItem alloc] initWithTitle:@"Done" style:UIbarbuttonItemStylePlain target:self action:@selector(doneTap:)];        _todoListVIEwController.navigationItem.leftbarbuttonItem = donebutton;        _completedListVIEwController.navigationItem.leftbarbuttonItem = donebutton;    }    return self;}

注意,我没有做任何事情:

> edgesForExtendedLayout
> automaticAdjustsScrollVIEwInsets
> extendedLayoutIncludesOpaquebars

iOS 7默认值遵循导航栏和标签栏(与上面的原始屏幕截图不同,当UITabbarController显示不正确时).

总结

以上是内存溢出为你收集整理的ios – UITabBarController – Child(Tab)ViewControllers的不正确和不一致的边界全部内容,希望文章能够帮你解决ios – UITabBarController – Child(Tab)ViewControllers的不正确和不一致的边界所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1100549.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存