简体   繁体   English

iOS状态栏-View Controller到Navigation Controller

[英]iOS status bar - View Controller to Navigation Controller

I have done a little research and understand that a quick fix for iOS 7+ suffering from the overlying status bar issue (introduced in iOS 7 with the new status bar layout) on a view controller is to put it in a Navigation Controller. 我进行了一些研究,并了解到,针对视图控制器上存在重叠状态栏问题(在iOS 7中引入了新的状态栏布局)的iOS 7+的快速解决方案是将其放入导航控制器中。

However, when I go to Xcode the option is greyed out. 但是,当我转到Xcode时,该选项显示为灰色。 What am I doing wrong? 我究竟做错了什么? (I am an Xcode beginner, so bear with me). (我是Xcode的初学者,所以请多多包涵)。

Is using a Navigation Controller the correct way to do it? 使用导航控制器是正确的方法吗?

Xcode屏幕截图

As you can see here, the Navigation Controller is behind the status bar, not extended below it: 如您在此处看到的,导航控制器在状态栏的后面,未在其下方扩展:

iOS萤幕撷取画面

Its looking like that your controller is already in a Navigation controller stack, thats why it is not showing the option to embed in Navigation controller. 看起来您的控制器已经在导航控制器堆栈中,这就是为什么它没有显示嵌入到导航控制器中的选项。 Check your storyboard. 检查您的情节提要。

You Create Xib its set the Top Bar or Navigation Bar, select the XIB then see the right side select Attributes Inspector then set the status bar, Top Bar etc, then see my screenshot below, 您在Create Xib中设置顶部栏或导航栏, 选择XIB,然后在右侧选择Attributes Inspector,然后设置状态栏,顶部栏等,然后在下面查看我的屏幕截图,

在此处输入图片说明 create UIBarbutton programmatically code is below, 下面UIBarbutton编程方式创建UIBarbutton代码,

viewDidLoad Method: viewDidLoad方法:

UIBarButtonItem *leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"imageName"] style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
[self.navigationItem setLeftBarButtonItem:leftBarButtonItem animated:NO];

its working for me, hope its helpful 它为我工作,希望它有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在导航控制器中,将忽略视图控制器的首选状态栏样式 - Preferred status bar style of view controller is ignored when in navigation controller iOS 7 - 隐藏子视图控制器上的状态栏 - iOS 7 - Hide status bar on a child view controller 呈现的视图控制器涵盖了iOS 7中的状态栏 - Presented view controller covers status bar in iOS 7 呈现视图控制器后更改iOS状态栏颜色或导航栏颜色? - Changing iOS status bar color or navigation bar color after presenting a view controller? IOS:导航栏 - 重新加载视图控制器 - IOS: Navigation Bar - Reload View Controller 带导航栏和视图控制器的自动布局(iOS 7) - Auto Layout with navigation bar and view controller (iOS 7) 有没有办法隐藏导航栏控制器,而不是IOS中的状态栏? - Is there a way to hide the navigation bar controller but not the status bar in IOS? 如何将视图控制器推送到iOS中标签栏中的导航控制器 - how to push a view controller to a navigation controller in a tab bar in iOS iOS 13:导航内的滚动视图 controller 不会在状态栏下 go - iOS 13: Scroll view inside navigation controller won't go under the status bar 导航控制器和状态栏问题 - Navigation controller and status bar issue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM