iOS7 Xcode实用程序应用程序 - Flipsideviewcontroller上的UINavigationBar没有正确间隔? [英] iOS7 Xcode utility app - UINavigationBar on Flipsideviewcontroller not spaced properly?

查看:99
本文介绍了iOS7 Xcode实用程序应用程序 - Flipsideviewcontroller上的UINavigationBar没有正确间隔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题,标准的flipsideviewcontroller UINavigationBar看起来像这样:

I have this issue, where as standard the flipsideviewcontroller UINavigationBar looks like this:

任何人对如何移动UINavigationBar或者阻止它们的丑陋都有任何想法?

Anybody have any ideas on how to move the UINavigationBar either down, or to stop the ugliness of it all?

推荐答案

这很棘手。 :)你需要为UINavigationBar设置一个委托 - 这可能是FlipsideViewController。您可以在故事板或代码中执行此操作 - 例如,如果您有导航栏的插座:

It's tricky. :) You need to set a delegate for the UINavigationBar - this will probably be the FlipsideViewController. You can do this in the storyboard, or in code - for example, if you have an outlet to the navigation bar:

-(void)viewDidLoad {
    [super viewDidLoad];
    self.navigationBar.delegate = self;
}

现在是重要部分:在委托中实现此方法:

Now comes the important part: implement in the delegate this method:

- (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar {
    return UIBarPositionTopAttached;
}

使用自动布局,导航栏的顶部也很重要顶部布局指南的零常量约束。这并不是很容易设置,因为Xcode中存在一个错误,它会尝试将其转换为导航栏的 bottom 中的错误约束。如果发生这种情况:

With auto layout, it is also crucial that the top of the navigation bar have a zero-constant constraint to the Top Layout Guide. This is not entirely easy to set up because there is a bug in Xcode that will try to turn this into a bad constraint from the bottom of the navigation bar. If that happens:


  • 删除顶部约束。

  • Delete the top constraint.

将导航栏向下移动到屏幕上。

Move the nav bar down the screen.

按住Control键并拖动以再次形成顶部布局指南的顶部约束。

Control-drag to form the top constraint to the Top Layout Guide again.

现在选择顶部约束并手动将其常量设置为0,以使导航栏再次向上移动。

Now select the top constraint and manually set its Constant to 0, to make the nav bar move back up again.

这篇关于iOS7 Xcode实用程序应用程序 - Flipsideviewcontroller上的UINavigationBar没有正确间隔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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