打开iPhone上的热点会导致我的应用程序屏幕向下移动 [英] Turning on hot spot on iPhone causes my app's screen shift downwards

查看:532
本文介绍了打开iPhone上的热点会导致我的应用程序屏幕向下移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在我的iPhone中打开人员HOT SPOT时,我的应用程序屏幕向下移动,我正在加载子视图。但在其他屏幕上却没有发生。它只发生在我加载子视图的屏幕上。所以有人能告诉我可能是什么问题吗?任何帮助将不胜感激。

When I turn on personnel HOT SPOT in my iPhone then my app's screen moves downwards in which I am loading sub views. But on other screens it doesn't takes place. It happens only on screen in which I am loading subviews. So can anybody tell me what can be the problem ? Any help will be appreciated.

推荐答案

您可以处理 UIApplicationWillChangeStatusBarFrameNotification UIApplicationDidChangeStatusBarOrientationNotification 通知会告诉您状态栏的新大小。避免对任何内容进行硬编码(例如40pt),而是从通知中获取新的状态栏框架。

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

如果你只需要高度,你可以轻松地将其拉出来。如果你需要做更复杂的状态栏框架,你必须将它从屏幕坐标转换到你自己的视图的坐标系统(例如,如果你有一个全屏幕布局视图控制器,需要在它下面放置东西) :

If you just need the height, you can pull that out easily. If you need to do anything more complicated with the status bar frame, you'll have to convert it from screen coordinates to your own view's coordinate system (e.g. if you have a full screen layout view controller and need to lay things out underneath 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's 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];

    // ...
}

转换坐标在iOS 7中尤其重要,默认情况下所有视图控制器都具有全屏布局。

Converting the coordinates is going to be especially important in iOS 7 where all view controllers have full screen layout by default.

这篇关于打开iPhone上的热点会导致我的应用程序屏幕向下移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆