Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何在UINavigationController中自动调整UIViewController的大小_Ios_Objective C_Iphone_Uiviewcontroller_Uinavigationbar - Fatal编程技术网

Ios 如何在UINavigationController中自动调整UIViewController的大小

Ios 如何在UINavigationController中自动调整UIViewController的大小,ios,objective-c,iphone,uiviewcontroller,uinavigationbar,Ios,Objective C,Iphone,Uiviewcontroller,Uinavigationbar,我在UINavigationController中有一个UIViewController。在viewDidLoad中,我向UIViewController添加了一个UIView(self.loadingView),其自动布局代码如下: [self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelatio

我在UINavigationController中有一个UIViewController。在viewDidLoad中,我向UIViewController添加了一个UIView(self.loadingView),其自动布局代码如下:

[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.loadingView attribute:NSLayoutAttributeWidth multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.loadingView attribute:NSLayoutAttributeHeight multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.loadingView attribute:NSLayoutAttributeTop multiplier:1 constant:0]];
[self.view addConstraint:[NSLayoutConstraint constraintWithItem:self.view attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:self.loadingView attribute:NSLayoutAttributeLeading multiplier:1 constant:0]];
运行之后,我发现self.loadingView比屏幕大,并且我看不到self.loadingView的底部,因为在这个视图上面有一个额外的UINavigationbar


我可以手动调整self.loadingView的大小来解决此问题,但如何自动调整大小。具体来说,我不想在我的项目中添加
self.loadingView.frame.height-=44

如何显示加载视图?在UINavigationBar下方显示它,而不是使用
self.loadingView.frame.height-=44
[self.loadingView setNeedsLayout];[self.loadingView layoutifneed]你能用详细的实现回答我的问题吗?我应该在哪里添加您在这里提到的代码。您可以发布有关附加UINavigationBar的相关cod吗?