问题
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