2

When i turn on Personnel Hotspot on under My iPhone settings the UI of My iPhone App gets displaced 20 pixels below.How can i deal with this problem.

Is there a way i can detect whether Hotspot is turned on or off.?

Thanks vikas

Srikar Appalaraju
  • 71,928
  • 54
  • 216
  • 264
Vikas Ojha
  • 444
  • 1
  • 8
  • 23

2 Answers2

6

You can get several sizes using the following selectors, whenever the hotspot or other notification appears the statusBarFrame will become 40px high.

CGRect rect;
rect = [[UIScreen mainScreen] bounds]; // Get screen dimensions
NSLog(@"Bounds: %1.0f, %1.0f, %1.0f, %1.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);

rect = [[UIScreen mainScreen] applicationFrame]; // Get application frame dimensions (basically screen - status bar)
NSLog(@"App Frame: %1.0f, %1.0f, %1.0f, %1.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);

rect = [[UIApplication sharedApplication] statusBarFrame]; // Get status bar frame dimensions
NSLog(@"Statusbar frame: %1.0f, %1.0f, %1.0f, %1.0f", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
Anton Banchev
  • 541
  • 8
  • 28
  • Hi, Thanks for your answer. just wanted to clear one point ,the moment hot spot appears on screen my status bar should remain at its original place coordinates however the Hotspot takes 20 pixels below the status bar ? OR Does the status bar moves 20 pixel upwards to -20 pixel Please clear.?........Also is there a Bool value through which i can check if a Hotspot is appearing non my screen right now or Not..? Thanks – Vikas Ojha Sep 25 '12 at 08:43
  • 1
    The status bar expands and becomes 20 pixels bigger, the position of the status bar does not change, only the size. There is no bool I think, however you can just check if statusbarframe.size.height>20 – Anton Banchev Sep 25 '12 at 10:42
1

You have a number of options to deal with this:

  • Use the proper auto resizing masks on your views for applications that support versions of iOS before iOS 6 and make sure all your custom views deal with setting up their auto resizing masks properly.
  • For applications that support iOS 6+, use auto layout and constraints.
  • For applications with a lot of custom drawing or views, override -viewWillLayoutSubviews on the view controller, when appropriate, and/or -layoutSubviews on custom views.
Jason Coco
  • 77,985
  • 20
  • 184
  • 180