1

I use the way here:

https://stackoverflow.com/a/18387241/2717264

everything ok, but when I presentViewController a UIImagePickerController, the window show like this:

enter image description here

than, I custom a pickerController subclass from UIImagePickerController, in the pickerController viewDidLoad add this code:

#define AppDelegate ((WeikeAppDelegate *)[[UIApplication sharedApplication] delegate])

AppDelegate.window.clipsToBounds = NO;
AppDelegate.window.frame =  CGRectMake(0, 0, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height + 20);
AppDelegate.window.bounds = CGRectMake(0, 0, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height);

it work fine, but when pickerController dismiss, window display incorrect again:

enter image description here

I try to solve it by adding this code in the viewWillDisappear of pickerController, but useless, any idea?

AppDelegate.window.clipsToBounds = YES;
AppDelegate.window.frame =  CGRectMake(0, 20, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height -20);
AppDelegate.window.bounds = CGRectMake(0, 20, AppDelegate.window.frame.size.width, AppDelegate.window.frame.size.height);
Community
  • 1
  • 1
Chris
  • 581
  • 3
  • 17
  • http://stackoverflow.com/a/19025547/1545180 use this. – Ganapathy Nov 19 '13 at 08:35
  • http://www.appcoda.com/customize-navigation-status-bar-ios-7/ – NANNAV Nov 19 '13 at 08:58
  • my viewControllers design by programming, any way without stroyboard? @Ganapathy – Chris Nov 19 '13 at 14:00
  • So you need to handle programmatically by adding 20pxl to all your controller if the device version is > IOS 7.0 – Ganapathy Nov 19 '13 at 14:02
  • @Ganapathy , I have do it, and it work fine, but when I presentViewController a UIImagePickerController, just like what I ask this question. – Chris Nov 19 '13 at 15:05
  • @NANNAV I have try, it didnot work, and I have downloaded your example and added a button to presentViewController a UIImagePickerController, then I see it also have the problem, the window show just like the screenshot I upload here the first one. – Chris Nov 19 '13 at 15:20

2 Answers2

2

Xcode 5 has iOS 6/7 Deltas which is specifically made to resolve this issue. In the storyboard, I moved my views 20 pixels down to look right on iOS 7 and in order to make it iOS 6 compatible, I changed Delta y to -20.

enter image description here

Since my storyboard is not using auto-layout, in order to resize the height of views properly on iOS 6 I had to set Delta height as well as Delta Y.

SampathKumar
  • 2,525
  • 8
  • 47
  • 82
0

I have solved it by doing lots of test, I set a 640*128(pixels) image as the background of the navigationbar, this is the image(40 pixels height black block as the statuebar and 88 pixels height block as the navigationbar):

enter image description here

then it display Correct in case of UIImagePickerControllerSourceTypeCamera,if u presentViewController the UIImagePickerController in the case of UIImagePickerControllerSourceTypePhotoLibrary(I think this will be also Suitable for presentViewController the other view controller with a navigationbar, but I haven't do a test yet), u should subclass from UIImagePickerController:

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
}


- (void)viewWillDisappear:(BOOL)animated
{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}

Prerequisites:

have this code in the your first view controller:

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)viewDidLoad
{
    /*navigation config*/
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"image-navigation-bk"]
                                                  forBarMetrics:UIBarMetricsDefault];

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

    if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)])
    {
        [self setNeedsStatusBarAppearanceUpdate];
    }
}
Chris
  • 581
  • 3
  • 17