UITableView partially hidden by UITabBar(UITableView 被 UITabBar 部分隐藏)
问题描述
我有一个 UITabBarController,其中包含一个 UINavigationController.在可见的 UIViewController 中,我以编程方式创建了一个 UITableView,如下所示:
I've got a UITabBarController which contains a UINavigationController. Within the visible UIViewController, I'm creating a UITableView programatically as follows:
self.voucherTableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
self.voucherTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
但是,UITabBar 与 UITableView 重叠.
However, the UITabBar is overlapping the UITableView.
当我输出 [[UIScreen mainScreen] applicationFrame] 的高度时,它返回 460.00 而应该是 367.00.
When I output the height of the [[UIScreen mainScreen] applicationFrame], it returns 460.00 whereas it should be 367.00.
在 Interface Builder 中,我使用模拟指标",它会自动将视图的高度设置为 367.00.
In Interface Builder, I'm using the 'Simulated Metrics' which automatically sets the height of the view to 367.00.
我是否缺少某些东西,无论我尝试什么,我都看不到我需要的 367.00 高度.
Is there something I'm missing, no matter what I try I can't see to get the 367.00 height that I need.
作为临时修复,我手动设置了 UITableView 的框架,这并不理想,所以最好弄清楚为什么这不起作用:
As a temp fix, I've set the frame of the UITableView manually, this isn't really ideal so it would be nice to work out why this isn't working:
self.voucherTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 367) style:UITableViewStylePlain];
推荐答案
你应该使用 self.view.bounds 而不是 [[UIScreen mainScreen] applicationFrame] 因为最后一个返回整个屏幕框架,而 self.view.bounds为您提供您正在搜索的视图范围.
You should use self.view.bounds rather than [[UIScreen mainScreen] applicationFrame] as the last one returns you the whole screen frame while self.view.bounds provides you with your view bounds wich seems what you are searching for.
这篇关于UITableView 被 UITabBar 部分隐藏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:UITableView 被 UITabBar 部分隐藏
基础教程推荐
- NSString intValue 不能用于检索电话号码 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
