How to know when StatusBar (iPhone) resized

I have a UITabBarController with 2 tabs . When resizing a StatusBar, resizing is very simple (emulator "Toggle Call Status Bar"). There is no other.

The problematic tab contains a static view that dynamically loads a particular viewdepending on certain things. When working with this setting, I found that the view of the main tab was not automatically sent, for example. viewWillAppear and viewWillDisappear messages in my dynamic subviews.

Apple docs explains this because dynamically added views were not recognized by the system.

@interface MyTabViewController : UIViewController
{
    UIView *mainView;
    FirstViewController *aController;
    SecondViewController *bController;
}
...
if (index == 0)
{
    self.aController = [[FirstViewController alloc]
        initWithNibName:@"FirstViewController" bundle:nil];            
    [self.mainView addSubview:aController.view];
    [self.aController viewWillAppear:YES];
}

StatusBar ? "DidChangeStatusBarFrame" , .

+3
3

?

, application:didChangeStatusBarFrame:?

0

, " ". (UIView autoresizingMask).

0

I'm not sure about this, but since you added these views programmatically, you may have forgotten to set the auto-size mask. Without it, the view will not automatically change when the frame of the status bar changes.

[newView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];

Hope this helps.

0
source

Source: https://habr.com/ru/post/1738957/


All Articles