3

I have UITabBarController with 2 tabs. One resizes just fine, when StatusBar size changes (emulator "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.

JOM
  • 8,139
  • 6
  • 78
  • 111

3 Answers3

0

Have you taken a look at this question?

Also, can we see your App Delegate code using application:didChangeStatusBarFrame:?

Community
  • 1
  • 1
makdad
  • 6,402
  • 3
  • 31
  • 56
  • My solution was to change the architecture: work with the system, not against it :) In other words I now have only one UIViewController (which contains one reused UITableView which dynamically changes dataSource and delegate) – JOM Dec 02 '10 at 04:28
  • 2
    When I tested didChangeStatusBarFrame, it only worked with rotation (checked events, even when app didn't rotate). Tethering or in-call were not recognized... http://stackoverflow.com/questions/2406175/why-is-uiapplicationwillchangestatusbarframenotification-not-sent-when-the-status – JOM Dec 02 '10 at 04:35
0

You could program a resize yourself, but usually this is done by using "auto resizing masks". (UIView has a property autoresizingMask).

Pieter Jongsma
  • 3,365
  • 3
  • 27
  • 30
  • I could, if system would tell me about it. Maybe "auto resizing" was setup in wrong way, since that application didn't support rotation at all. – JOM Dec 02 '10 at 04:39
0

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.