Turning on a hotspot on the iPhone causes the application screen to change down

When I turn on HOT SPOT staff on my iPhone, then the screen of my application moves down, in which I load sub-views. But on other screens this does not happen. This only happens on the screen in which I load subviews. So can someone tell me what could be the problem? Any help would be appreciated.

+4
source share
3 answers

whenever a hotspot or other notification appears, the status of the BarFrame 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); 
+2
source

You can handle the notifications UIApplicationWillChangeStatusBarFrameNotification and UIApplicationDidChangeStatusBarOrientationNotification , which will tell you the new size of the status bar. Avoid hard coding (e.g. 40pt) and instead get a new status break from the notification.

If you just need height, you can easily pull it out. If you need to do something more complex with the status bar frame, you will have to convert it from screen coordinates to your own view coordinate system (for example, if you have a full-screen mockup view manager and need to put things under it)

 - (void)statusBarFrameWillChangeNotification:(NSNotification *)notification { NSValue *rectValue = notification.userInfo[UIApplicationStatusBarFrameUserInfoKey]; CGRect statusBarFrame = [rectValue CGRectValue]; // if you just need the height, you can stop here // otherwise convert the frame to our view coordinate system UIWindow *targetWindow = self.view.window; // fromWindow:nil here converts from screen coordinates to the window CGRect statusBarFrameWindowCoords = [targetWindow convertRect:statusBarFrame fromWindow:nil]; CGRect frameRelativeToOurView = [self.view convertRect:statusBarFrameWindowCoords fromView:targetWindow]; // ... } 

Coordinate conversion will be especially important in iOS 7, where by default all view controllers have a full-screen layout.

+2
source

The status bar expands and becomes 20 pixels larger, the position of the status bar does not change, but only the size. I don't think bool, but you can just check

 statusbarframe.size.height>20 
0
source

Source: https://habr.com/ru/post/1493659/


All Articles