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

前提是你 提交于 2019-11-30 10:39:13

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.

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