Domanda

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

È stato utile?

Soluzione

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);

Altri suggerimenti

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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top