UITableViewController中的状态栏
我将 UITableViewController
用于 UIButton 导航控制器
/ code>已按下。按下按钮时, TableViewController
出现时没有状态栏。如果我选择 TableViewController
的单元格,然后getBack状态栏显示正确。我不知道发生这种情况的原因。我想每次都出现状态栏。我试图从StoryBoard设置状态栏,但它没有用。我也从这里以编程方式尝试了很多解决方案。
I use an UITableViewController
into a Navigation Controller
that comes up when an UIButton
pressed. When the button has been pressed the TableViewController
comes up without status bar. If i select a cell of the TableViewController
and then getBack the Status Bar appears properly. I don't know the reason that this happens. I want the Status Bar to appear every time. I tried to set Status Bar from StoryBoard but it did't work. I also tried a lot of solutions programmatically from here.
这是Storyboard的一部分,它显示了 TableViewController
和已选择的选项。
This is the part of Storyboard that shows the TableViewController
and the options that have been selected.
这是错误的结果:
如果我选择一个单元格并返回 TableViewController
我有这个结果:
If I select a cell and get back to the TableViewController
I have this result:
我希望每次都得到第三张照片的结果。
I want to have the result of third pic every time.
P.S。在我的.plist文件中,我将基于控制器的View状态栏外观设置为YES。
P.S. In my .plist file I have View controller-based status bar appearance set to YES.
我已添加到我的 viewDidLoad
这一行:
I have added to my viewDidLoad
this Line:
[self setNeedsStatusBarAppearanceUpdate];
低于 viewDidLoad
此方法:
-(UIStatusBarStyle)preferredStatusBarStyle{
return UIStatusBarStyleLightContent;
}
它只显示电池寿命。
如果有人将来遇到同样的问题,这就是答案。
If anyone has the same problem in future, this is the answer.
步骤1:将此项添加到.plist文件中。
Step 1: Add this to your .plist file.
查看基于控制器的状态栏外观--->否
View controller-based status bar appearance ---> NO
第2步:这两行到您的appDelegate进入 didFinishLaunchingWithOptions 方法。
Step 2: These two lines to your appDelegate into didFinishLaunchingWithOptions method.
[[UIApplication sharedApplication] setStatusBarHidden:NO];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];