gpt4 book ai didi

objective-c - uiview 的自动调整大小

转载 作者:太空狗 更新时间:2023-10-30 03:40:34 25 4
gpt4 key购买 nike

我在 UITabController 中有一个 UIView。并且里面有一个UITableView

在通话状态栏中切换时,它不会执行任何操作,并且 View 不会自动调整大小。

它假定正确的大小基于调用 UIStatusBar 在应用程序启动时是否被切换,但如果 UIStatusBar 在应用程序运行时被切换则没有任何变化。

带有 UINavigationController 的另一个选项卡 View 似乎可以很好地调整大小。

这是代码

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

最佳答案

您是否正确设置了 UIView 的调整大小掩码?你可以在 Interface Builder 中的大小选项卡中设置它,它是你可以单击的红线。

您还可以使用以下代码在代码中设置它:

[view setAutoresizingMask:UIViewAutoresizingFlexibleWidth | 
UIViewAutoresizingFlexibleHeight];

还要确保 super View 已将 autoresizesSubviews 设置为 YES。

您可以在 UIView documentation 中找到更多相关信息.

关于objective-c - uiview 的自动调整大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3342424/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com