iOS7 Xcode utility app - UINavigationBar on Flipsideviewcontroller not spaced properly?

会有一股神秘感。 提交于 2019-12-18 13:50:52

问题


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

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


回答1:


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;
}

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-drag to form the top constraint to the Top Layout Guide again.

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



来源:https://stackoverflow.com/questions/22231843/ios7-xcode-utility-app-uinavigationbar-on-flipsideviewcontroller-not-spaced-pr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!