如何考虑其他 UIElement 的高度来检索可用高度?
我怎样才能获得可用高度?
我尝试过:
NSLog(@"%f", [self bounds].size.height);
NSLog(@"%f", [self frame].size.height);
NSLog(@"%f", [[UIScreen mainScreen] bounds].size.height);
我总是得到屏幕的高度。 但实际高度要小一些。信息栏在顶部+导航栏,高度更小。
编辑: 我需要以编程方式检索高度。那就是如果有一个 TabBar 并且我的视图并不总是在 NavBar-Controller 中。也许没有导航栏。
How can i get the available height?
I tried:
NSLog(@"%f", [self bounds].size.height);
NSLog(@"%f", [self frame].size.height);
NSLog(@"%f", [[UIScreen mainScreen] bounds].size.height);
I get always the screen's height.
But the actual height is smaller. With Informationbar on the top + Nav-Bar, the height is smaller.
EDIT:
I need to retrieve the height programmatically. Thats if there is a TabBar and my View is not always in a NavBar-Controller. Maybe there is no NavBar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
导航栏的预定义高度为 44,您永远无法更改。通过信息栏,我认为你的意思是状态栏,其固定高度为20。iPhone屏幕的总高度是 480。你进行计算...:)
但是,如果您想要这样的屏幕的高度,那么在笔尖中总是模拟状态栏和导航栏,然后拥有所有的 UI 元素。之后,当你要做的时候
你会得到你的视图的高度
Navigation bar has a predefined height of 44 which you can never change. And by information bar, i think u mean the status bar which has a fixed height of 20. Total height of iPhone screen is 480. U do the calculations... :)
However, if you want the height of such a screen then in the nib always have status bar and navigation bar simulated and then have all the UI elements for that. After that, when you'll do
you'll get the height of your view
或者
OR