gpt4 book ai didi

iphone - 动态定位从 StoryBoard 创建的 UITableView

转载 作者:行者123 更新时间:2023-11-28 22:29:53 25 4
gpt4 key购买 nike

我在 StoryBoard 上创建了一个 UITableView,它并没有填满整个屏幕,它开始往下一点。我这样做是因为我希望其他内容(例如标签和按钮)位于我以编程方式创建的内容之上。

enter image description here

当我在模拟器中为普通 iPhone 和 iPhone 4 retina 运行应用程序时,一切都正确定位。

enter image description here

但是,当为 iPhone 5 运行时,UITableView 在按钮和标签的顶部及其开始位置之间有一个间隙。

enter image description here

我尝试编写代码来检查 iPhone 5,然后将 UITableView 重新定位到更高的位置,但是,无论我为框架输入什么值,UITableView永远不动。

- (void) viewWillAppear:(BOOL)animated
{
if([iDevice screenResolutionHeight] == IPHONE_5)
{
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.mytableView.frame.size.width,self.mytableView.frame.size.height)];
view.backgroundColor = [UIColor whiteColor];
}
}

最佳答案

您的表格 View 似乎有高度限制。您应该在 super View 的底部创建一个约束,在上部蓝色 View (带有 All 和 Filter 的 View )的底部创建另一个约束。如果你给那个蓝色 View 一个高度约束,那么你应该能够移除 TableView 的高度约束。

关于iphone - 动态定位从 StoryBoard 创建的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17731273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com