Ios 如何在UINavigationController中自动调整UIViewController的大小
我在UINavigationController中有一个UIViewController。在viewDidLoad中,我向UIViewController添加了一个UIView(self.loadingView),其自动布局代码如下: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
[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吗?