当出现通话或热点状态栏时,我的应用程序的布局被破坏了

问题描述 投票:0回答:1

我在测试我的应用程序时遇到了问题,一切都运行得很好,直到我打开个人热点并且蓝色条出现在顶部,所有标签和按钮都向下移动:

enter image description here

viewDidLoad
的代码是:

- (void)viewDidLoad
{
    day1Times = [[NSMutableArray alloc] init];
    day2Times = [[NSMutableArray alloc] init];
    day3Times = [[NSMutableArray alloc] init];
    day4Times = [[NSMutableArray alloc] init];
    day5Times = [[NSMutableArray alloc] init];
    day6Times = [[NSMutableArray alloc] init];
    day7Times = [[NSMutableArray alloc] init];
    [self performSelector:@selector(sendTokenIDSelector) withObject:nil afterDelay:0.1];
    [self performSelectorInBackground:@selector(getTimes) withObject:nil];
    [super viewDidLoad];
   
}

约束配置如下:

enter image description here

如何固定它们的位置并使其无论状态栏如何都不会移动?

ios objective-c layout autolayout
1个回答
1
投票

问题是由于您的视图自动调整大小蒙版造成的。您应该将它们挂在边缘,这样当通知发生时它们就不会拉伸。

使用“工具”->“尺寸检查器”或 Command+3 打开尺寸检查器。

确保上边距的支柱已启用(由红色实线表示)。因此,即使超级视图发生变化,您也可以确保拥有恒定的边距。

© www.soinside.com 2019 - 2024. All rights reserved.