views:

253

answers:

2

I have a uiview in a tab controller

And in it is a uitableview

When toggling in call status bar it doesn't do anything

The view is not automatically resized

It assumes the right size based on whether the in call status bar was toggled when the app starts but if the status bar is toggled whilst the app is running nothing changes

another tab view with a navigation controller seems to resize fine

Here is the code

if ([indexPath indexAtPosition:0] == 0 || [indexPath indexAtPosition:0] == 1) {
        if (!airportChooser) {
            airportChooser = [[AirportChooserController alloc] init];
            airportChooser.targetController = self;
            airportChooser.view.autoresizesSubviews = YES;  
            airportChooser.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
            [airportChooser.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];
        }
        airportChooser.target = [indexPath indexAtPosition:0];
        [self.parentViewController.parentViewController.view addSubview:airportChooser.view];
        self.parentViewController.parentViewController.view.autoresizesSubviews = YES;
        self.parentViewController.parentViewController.view.contentMode = UIViewContentModeRedraw;
        [self.parentViewController.parentViewController.view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];
        airportChooser.view.contentMode = UIViewContentModeRedraw;
        //[airportChooser open];
    }
+1  A: 

Did you set the resizing mask of the UIView correctly? You can set it in Interface Builder in the size tab, it's the red lines that you can click.

You can also set it in code using something like:

[view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth];

Also make sure the superview has set autoresizesSubviews to YES.

You can find more information about this in the UIView documentation.

klaaspieter
I've done both of these but still no luckI'm now adding the view to the window (fixed the previous example by using push view controller) and it has the same effect as described beforeIt adds the view in the right place depending on the position on the status bar but wont adjust once it is openif i add the sub view in application did finish launching it works fine but if i add it later as the result of user input it doesnt
msaspence
A: 

Whilst klaaspeiter's answer makes sense and in some cases may be the right answer in my specific case it was because I was adding a sub view to a UINavigationController's view with addSubview instead of pushViewController:view animated:NO;

msaspence
whilst this is a way round the problem it is not a fix for when you want to use addSubview as I now do :(
msaspence