How to know when StatusBar size changed (iPhone)
I have UITabBarController with 2 tabs. One resizes just fine, when StatusBar size changes (emulator开发者_如何学Go "Toggle In-Call Status Bar" menu item). The other one doesn't.
The problematic tab item contains a static view, which dynamically loads one or another view depending on certain things. While getting this setup working I discovered that main tab view did NOT automagically send e.g. viewWillAppear and viewWillDisappear messages to my dynamic subviews.
Apple docs explained this was 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];
}
How can I get StatusBar size changed event into my dynamic subviews? The "didChangeStatusBarFrame" doesn't work, as documented elsewhere.
Have you taken a look at this question?
Also, can we see your App Delegate code using application:didChangeStatusBarFrame:
?
You could program a resize yourself, but usually this is done by using "auto resizing masks". (UIView has a property autoresizingMask).
I'm not sure about it but since your were adding those views programmatically maybe you forgot to set the autoresize mask. Without it the view won't resize automatically when the status bar frame changes.
[newView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];
I hope it helps.
精彩评论