Domanda

For iOS 7, I had status bar problem. For that I solved it by using below code in Appdelegate

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
    [[UIApplication sharedApplication] 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,0, self.window.frame.size.width, self.window.frame.size.height);
}

All is working perfectly.

Only it gives problem while taking photo.

When I open camera or photo gallery, I still see status bar and because of that I see half of the navigation title as shown below.

enter image description here

Any idea how can I overcome this error?

The problems are :

  1. Photo Gallery/ Camera comes like above image

  2. If I click cancel, my view is shifted 20px up automatically.

È stato utile?

Soluzione 3

I faced this problem wih one of my project. We didn't even have the xib for many classes. So all I could do is reset the frame once again in the delegate functions.

   [self.navigationController dismissViewControllerAnimated:YES
                                              completion:^{
                                                  [self.navigationController.view setFrame:CGRectMake(self.navigationController.view.frame.origin.x, [UIApplication sharedApplication].statusBarFrame.size.height, self.navigationController.view.frame.size.width, [[UIScreen mainScreen] bounds].size.height-[UIApplication sharedApplication].statusBarFrame.size.height)];
                                              }];

I put this in the finish/cancel delegate methods of photo/camera picket, mail picker.

Altri suggerimenti

Instead of:

self.window 

Use this:

[[self view] window]

Try Like this:

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

I guess you are using the UINavigationController. There is nothing to do with the frame nor to do something with the Status Bar, If you are using UINavigationController. Please prefer the below code to set the UINavigationController along with Status bar set up. Else you can display the code, Will help you fix this.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UIApplication sharedApplication] setStatusBarHidden:NO];
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque];
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.viewController = [[ExViewController alloc] initWithNibName:@"ExViewController" bundle:nil];
    self.window.rootViewController = self.viewController;

    self.mainViewNavigation = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = mainViewNavigation;


    [self.window addSubview:self.mainViewNavigation.view];
    [self.window makeKeyAndVisible];
    return YES;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top