开发者

autoresize of uiview

I have a UIView in a UITabController. And there is a UITableView in it.

When toggling in call status bar it doesn't do anything and the view is not automatically resized.

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

Another tab view with a UINavigationController seems to resize fine.

Here is the code

if ([indexPath indexAtPosition:0] == 0 || [indexPath indexAtPosition:0] == 1) {
        if (!airportChooser) {
            airportChoos开发者_JAVA百科er = [[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];
    }


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 | 
                          UIViewAutoresizingFlexibleHeight];

Also make sure the superview has set autoresizesSubviews to YES.

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


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;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜