如何调整 UITableView 控制器中表视图的大小?

发布于 2024-12-15 00:34:57 字数 86 浏览 4 评论 0原文

我有一个 UINavigationController ,其中包含 UITableViewController 的视图。如何从导航控制器内调整表格视图的大小?

I have a UINavigationController that contains the view of a UITableViewController. How can I resize the table view from within the navigation controller?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

秋叶绚丽 2024-12-22 00:34:57

不太确定这是否是您正在寻找的东西,但听起来足够接近。这会将 tableView 的大小调整为您指定的任何像素大小。它也会在过渡中执行此操作(因此它不会只是跳转到大小)。如果需要,您可以删除过渡。

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];

CGRect rect = myTableView.frame;
rect.size.height = 400;
rect.size.width = 300;
myTableView.frame = rect;
[UIView commitAnimations];

Not exactly sure if this is what you are looking for but its sounds close enough. This will resize your tableView to whatever pixel size you specify. It will do it in a transition too (so it doesnt just jump to size). You can remove the transition if you wanted.

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];

CGRect rect = myTableView.frame;
rect.size.height = 400;
rect.size.width = 300;
myTableView.frame = rect;
[UIView commitAnimations];
薆情海 2024-12-22 00:34:57
[[self tableView] setFrame:CGRectMake(0, 0, 320, 480)];
[[self tableView] setFrame:CGRectMake(0, 0, 320, 480)];
枕头说它不想醒 2024-12-22 00:34:57

也许这个方法将帮助您调整表行的大小:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

Maybe this method will help you to resize the table rows:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文