Resize for in-call status bar?

前端 未结 11 564
名媛妹妹
名媛妹妹 2020-11-29 03:06

How can I make my view resize in response to the in-call status bar from my nib?

I figured it would just be setting the resize properties, but they\'re not enabled f

相关标签:
11条回答
  • 2020-11-29 03:40

    You're looking for -[UIApplication statusBarFrame] and, in your UIApplicationDelegate, you should implement this delegate method to be notified of when the status bar's frame changes:

    - (void)application:(UIApplication *)application didChangeStatusBarFrame:(CGRect)oldStatusBarFrame  
    
    0 讨论(0)
  • 2020-11-29 03:40

    this works for me perfectly when my application is running in background and I press command + T. In my scenario , the root controller is my tab bar controller and I am readjusting my nav controller inside each tab.

    - (void)application:(UIApplication *)application willChangeStatusBarFrame:(CGRect)newStatusBarFrame{
    [UIView animateWithDuration:0.35 animations:^{
        CGRect windowFrame = ((UINavigationController *)((UITabBarController *)self.window.rootViewController).viewControllers[0]).view.frame;
        if (newStatusBarFrame.size.height > 20) {
            windowFrame.origin.y = newStatusBarFrame.size.height - 20 ;// old status bar frame is 20
        }
        else{
            windowFrame.origin.y = 0.0;
        }
        ((UINavigationController *)((UITabBarController *)self.window.rootViewController).viewControllers[0]).view.frame = windowFrame;
    }];
    

    }

    0 讨论(0)
  • 2020-11-29 03:44

    I was having the same problem. What I did was this.

    1. Open the xib file in IB
    2. All interface elements are by default attached to move along with with top and shown in the 'Autosizing' property in the 'Size Inspector'. So, for the UI elements at the bottom of the screen, remove the link from top and instead make the link from bottom. Leave all the others as is.
    3. Problem Solved!!!

    I hope I was clear.

    0 讨论(0)
  • 2020-11-29 03:48

    None of the solutions posted before worked for me. What did work for me was that I didn't have my constraints set up properly for my views. In my situation, I had two different container views within my view.

    View of scene in storyboard.

    The bottom (in the list) container view was a UITableView, which was not scrolling correctly to the bottom of the table. The reason was that the offset of the in-call status bar was causing the origin (top-left corner) of the UITableView to change, but the size would remain this same. This meant that the bottom of the table was off screen!

    The solution was to correctly set the Autoresizing height constraint properly. In the screenshot below, it is the vertical arrows in the middle of the Autoresizing box.

    enter image description here

    0 讨论(0)
  • 2020-11-29 03:51

    The solution is to ensure you have made your window key:

    [window makeKeyAndVisible];
    

    If you don't do that the subview does not get resized automatically, but there are no other symptoms as far as I know.

    0 讨论(0)
提交回复
热议问题