4

I am working in IOS application where all the work is done programmatically and we haven't used autolayout in complete application.

But I am facing one issue here from long time that when I got call or if my hotspot is on in that case my device status bar height changes.

So In this case how I can manage the application frame so that my UIView's will be managed.

Thank you in advance.

Pradumna Patil
  • 2,180
  • 3
  • 17
  • 46

2 Answers2

0

A good way is to set the views and subviews autoresizing correctly through code(in your case).

OR Add this method to your AppDelegate.m :

-(void)application:(UIApplication *)application didChangeStatusBarFrame (CGRect)oldStatusBarFrame 
{
   // update layout
}

You can update the layout here with code.

Try this for autoresizing views:

view.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
Arpit Dongre
  • 1,683
  • 19
  • 30
  • Thank you @Arpit Dongre. I have tried with this method and also with the different notifications available from where I can get the status bar height. But I want to know is there any way I can manage UI once I will get the height. – Pradumna Patil Apr 03 '17 at 08:01
  • @PradumnaPatil Did you try autoresizing? I have updated my answer. – Arpit Dongre Apr 03 '17 at 12:33
0

Whenever the height of the status bar changes the following functions will be called. Just add these functions to your AppDelegate.m file. They will be called when the status bar changes its height. One of them is called before and the other after the change.

//Called before the change
- (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame
{
//Change the size of Window
self.window.frame = CGRectMake(0.0f, 60.0f, 200.0f, 200.0f);
//In your case it will be
//self.window.frame = CGRectMake(0.0f, 40.0f, self.window.frame.size.width, self.window.frame.size.height - 40);
} 

//Called after the change
//- (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame{
//Change the size of Window
//}

Starting :

enter image description here

Changing statusBar Height by toggling in-Call Status Bar

enter image description here

Final Result with Changed Frame:

enter image description here Hope this helps. Happy Coding. Reference

Community
  • 1
  • 1
Md. Ibrahim Hassan
  • 5,359
  • 1
  • 25
  • 45