Personal Hotspot breaks UI layout

孤人 提交于 2019-12-06 15:01:48

问题


When the personal Hotspot is activated and bar resizes itself to 40px, the view does not resize correctly. The bottom goes 20px below the screen instead of being resized.

I am using Auto Layout in all my View Controllers but even though my app UI breaks like the image shows below.

Any help would be great.!


回答1:


Register this notification in your viewdidload

- (void)viewDidLoad {
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(statusBarFrameWillChange:)name:UIApplicationWillChangeStatusBarFrameNotification object:nil];
}



  - (void)statusBarFrameWillChange:(NSNotification*)notification
{
     NSLog(@"STATUS BAR UPDATED");
int statusHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
NSLog(@"status bar height  %d", statusHeight);
    // Here you can do your constraint adjustments accordingly
}

you can find a nice tutorial here (in swift) http://studyswift.blogspot.in/2015/12/adjust-ui-components-programmatically.html




回答2:


You can check my previous answer iOS App layout is wrong with calling status bar

Technically same thing is happening here which is breaking your view's autolayout.



来源:https://stackoverflow.com/questions/44537654/personal-hotspot-breaks-ui-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!