Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7 Status bar with Phonegap

In iOS 7, Phonegap applications will appear underneath the status bar. This can make it difficult to click on buttons/menus that have been placed at the top of the screen.

Is there someone who knows a way to fix this status bar issue on iOS 7 in a Phonegap application?

I've tried to offset the entire web page with CSS but it doesn't seem to work. Is there a way to like offset the entire UIWebView or just make the status bar behave like it did in iOS6?

Thanks

like image 279
Luddig Avatar asked Oct 06 '13 14:10

Luddig


2 Answers

I found an answer on another thread, but I'll answer the question in case someone else wonders.

Just replace the viewWillAppear in MainViewController.m with this:

- (void)viewWillAppear:(BOOL)animated {     // View defaults to full size.  If you want to customize the view's size, or its subviews (e.g. webView),     // you can do so here.     // Lower screen 20px on ios 7     if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {         CGRect viewBounds = [self.webView bounds];         viewBounds.origin.y = 20;         viewBounds.size.height = viewBounds.size.height - 20;         self.webView.frame = viewBounds;     }     [super viewWillAppear:animated]; } 
like image 54
Luddig Avatar answered Oct 18 '22 16:10

Luddig


In addition to Ludwig Kristoffersson's resize fix, I recommend changing status bar color:

- (void)viewDidLoad {     [super viewDidLoad];     // Do any additional setup after loading the view from its nib.      if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {         CGRect viewBounds = [self.webView bounds];         viewBounds.origin.y = 20;         viewBounds.size.height = viewBounds.size.height - 20;         self.webView.frame = viewBounds;     }     self.view.backgroundColor = [UIColor blackColor]; } -(UIStatusBarStyle)preferredStatusBarStyle{     return UIStatusBarStyleLightContent; } 
like image 29
Alex L Avatar answered Oct 18 '22 15:10

Alex L