简体   繁体   English

ios 7中显示模型视图控制器时出现状态栏问题

[英]status bar issue while presenting model view controller in ios 7

I have returned in 我回来了

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];

    RootViewController *rvc = [[[RootViewController alloc] init] autorelease];
    UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:rvc] autorelease];

    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];
    return YES;

}

View controller-based status bar appearance  is  YES in plist file

when i am pushing view controllers status bar is looking great. 当我推动视图控制器状态栏看起来很棒。 As showing in following image. 如下图所示。

在此处输入图片说明

but when i am presenting modelviewcontroller it look as following. 但是当我介绍modelviewcontroller时,它看起来如下。

在此处输入图片说明

I have written following code in viewDidLoad method of viewcontroller which I am presenting 我在演示的viewcontroller的viewDidLoad方法中编写了以下代码

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
    // iOS 7
    navBar.frame = CGRectMake(navBar.frame.origin.x, 20, navBar.frame.size.width, 44);
}

I want to display black status bar when presentingmodelview. 我要在呈现模型视图时显示黑色状态栏。 But it is not displaying. 但是它没有显示。 I tried with 我尝试过

View controller-based status bar appearance is NO also in plist file but it is not working. 在plist文件中,基于View Controller的状态栏外观也为NO,但无法正常工作。

My code is working great in all ios version below 7.0 but not in ios 7.0 and above. 我的代码在7.0以下的所有ios版本中都能很好地工作,但在7.0或更高版本中却不能。

Any solution for this ? 有什么解决办法吗? Let me know if any one not getting my question. 让我知道是否有人回答我的问题。

Good solution found in this question . 这个问题找到了很好的解决方案。

1) Set UIViewControllerBasedStatusBarAppearance to NO in info.plist (To opt out of having view controllers adjust the status bar style so that we can set the status bar style by using the UIApplicationstatusBarStyle method.) 1)在info.plist中将UIViewControllerBasedStatusBarAppearance设置为NO(以选择不让视图控制器调整状态栏样式,以便我们可以使用UIApplicationstatusBarStyle方法设置状态栏样式。)

2) In AppDelegate's application:didFinishLaunchingWithOptions, call 2)在AppDelegate的应用程序中:didFinishLaunchingWithOptions,调用

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    [application setStatusBarStyle:UIStatusBarStyleLightContent];
    self.window.clipsToBounds =YES;
    self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);

    self.window.bounds = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height);
}
return YES;

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM