1

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. enter image description here

Any help would be great.!

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
Nilesh
  • 533
  • 7
  • 19

2 Answers2

2

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

Anshad Rasheed
  • 2,526
  • 1
  • 14
  • 32
1

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.

Aakash
  • 2,239
  • 15
  • 23
  • You mean I have to add constraint top of the super view, not TLG, right? – Nilesh Jun 14 '17 at 07:24
  • I have added constraint top of the super view but not solved the issue. – Nilesh Jun 14 '17 at 07:37
  • Yes, the same issue occurred. – Nilesh Jun 14 '17 at 07:50
  • If it doesn't work in your case then you need to adjust the constraint in viewDidLayoutSubviews() as whenever there will be change in status bar height this method will be called you can check height of status bar here and perform actions accrodingly – Aakash Jun 14 '17 at 07:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/146612/discussion-between-nilesh-and-aakash). – Nilesh Jun 14 '17 at 08:02