UINavigationBar的重叠UITableView的编程时设置提示 [英] UINavigationBar overlaps UITableView when programatically setting prompt

查看:153
本文介绍了UINavigationBar的重叠UITableView的编程时设置提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个的UINavigationController 包含一个的UITableViewController 。该导航控制器推周围其他UITableViewControllers,最终这些表视图控制器会有一个提示。

I have a UINavigationController which contains a UITableViewController. This navigation controller pushes other UITableViewControllers around and eventually these table view controllers will have a prompt.

问题是,当我设置提示编程它重叠它下面的表视图的内容。

The problem is when I set this prompt programatically it overlaps the content of the table view underneath it.

(搜索栏是由导航栏隐藏)

(A search bar is being hidden by the navigation bar)

我在SO环顾四周,发现<一个href=\"http://stackoverflow.com/questions/19460305/uinavigationbar-prompt-overlaps-the-screen-content\">this回答。我想建议有两种不同的方式在受影响的视图控制器,但没有改变:

I was looking around in SO and found this answer. I tried the suggestion there in two different ways in the affected view controller but nothing changed:

override func viewDidLoad() {
    super.viewDidLoad()
    self.edgesForExtendedLayout = .None;
    self.extendedLayoutIncludesOpaqueBars = false;
    self.navigationItem.title = NSLocalizedString("Add Anime or Manga", comment: "")
    self.navigationItem.prompt = NSLocalizedString("Search media belonging to this series.",  comment: "")
}

-

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationItem.title = NSLocalizedString("Add Anime or Manga", comment: "")
    self.navigationItem.prompt = NSLocalizedString("Search media belonging to this series.",  comment: "")
    self.edgesForExtendedLayout = .None;
    self.extendedLayoutIncludesOpaqueBars = false;
}

在链接的相同的答案注释,以这个苹果直营店从上互相重叠preventing意见。问题是的UITableViewController 不出现有顶部/底部布局指导,所以我不能创建一个约束(<一个href=\"http://stackoverflow.com/questions/24085152/x$c$c-5-not-displaying-top-bottom-layout-guides-for-tableviewcontrollers\">another SO回答说具有表视图控制器说布局无关)。

A comment in that same answer linked to this Apple guide on preventing views from overlapping each other. The problem is UITableViewController doesn't appear to have top/bottom layout guides so I can't create a constraint (another SO answer says having said layouts in table view controllers is irrelevant).

因此​​我已用尽我的所有选项。任何帮助将AP preciated。

As such I have exhausted all my options. Any help will be appreciated.

推荐答案

我试图重现您的问题,看来,当不是所有的 viewControllers 有一个提示导航栏不知何故不能正确调整

I have tried to reproduce your problem and it seems that when not all the viewControllers have a prompt the navigationBar is somehow not resizing properly.

看来你需要以某种方式触发布点的的UINavigationController 。我可以使它工作的唯一方法是正确的在 viewWillAppear中加入这样的:

It seems you need to somehow trigger the layouting for the UINavigationController. The only way I could make it work properly was by adding this in viewWillAppear:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [self.navigationController setNavigationBarHidden:YES];
    [self.navigationController setNavigationBarHidden:NO];

}

这也许提示,就是要在整个应用程序(指具有一个用于所有viewControllers或没有人)一贯使用的,这就是为什么的UINavigationController 不布局它的子视图时,它改变了。

Maybe this prompt is meant to be used consistently across the entire application (meaning having one for all viewControllers or none of them), that's why the UINavigationController does not layout it's subviews when it changes.

希望这也适用于你。

这篇关于UINavigationBar的重叠UITableView的编程时设置提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆