简体   繁体   English

使用情节提要板时,UIView的高度未考虑导航栏

[英]UIView's height not taking into account the Navigation Bar when using Storyboards

I've seen questions that look like this but the misunderstanding of people asking them was that they checked their UIView 's height on viewDidLoad: and when they checked it again on viewDidAppear: the result was as expected. 我见过类似的问题,但是人们问他们的误解是他们在viewDidLoad:上检查了UIView的高度,而在viewDidAppear:再次检查了它的高度viewDidAppear:结果是预期的。

So I'm checking (and most importantly using the value for some animations) and the height of the view I get doesn't take into account the UINavigationBar present. 因此,我正在检查(最重要的是使用某些动画的值),并且所获得的视图高度未考虑存在的UINavigationBar The thing to note is that I'm using a UIStoryboard and autolayout . 需要注意的是,我正在使用UIStoryboardautolayout

Any hints of why I'm getting the height of the whole screen and how can I get the correct value? 为什么我要获得整个屏幕的高度以及如何获得正确的值?

Thank you 谢谢

Try setting the translucency of your navigation bar to NO in your storyboard file and get the frame of the view from the view's -(void)didLayoutSubviews method or the view controller's -(void)viewDidLayoutSubviews method. 尝试在情节-(void)didLayoutSubviews文件中将导航栏的透明度设置为NO,然后从视图的-(void)didLayoutSubviews方法或视图控制器的-(void)viewDidLayoutSubviews方法获取视图的框架。 These get called when a view's frames have been updated and the view's layout is finalised (and on refreshes, so you might want to put in a check for the first run). 当视图的框架已更新且视图的布局已完成(以及刷新时,因此您可能需要检查一下首次运行)时,将调用这些方法。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用UIView作为导航栏的缺点 - Cons of using a UIView as a Navigation Bar 在Xcode中添加布局约束时考虑导航栏和Tab tar - Taking into account navigation bar and tab tar when adding layout constraints in Xcode 跨多个故事板的导航栏 - Navigation Bar Across Multiple Storyboards 使用情节提要板在什么阶段设置UIView委托 - At what stage does UIView delegate gets set when using storyboards 更改UITableViewCell(故事板)内部的UIView的高度 - Change height of UIView inside of UITableViewCell (Storyboards) 双击UIview时隐藏导航栏 - Hide navigation bar when double click on UIview 在导航栏中将其用作titleView时,增加UIProgressView高度 - increase UIProgressView height when using it as titleView in navigation bar 在导航控制器和标签栏之间找到主UIView的高度的问题 - Issue with finding the height of the main UIView between a Navigation Controller and Tab Bar 使用情节提要板时如何使用Typhoon导航到导航控制器中的控制器 - How to navigate to a controller in a navigation controller using Typhoon when using storyboards UITextView在键入/不使用故事板时动态更改的高度 - UITextView height to change dynamically when typing / without using storyboards
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM