如何动态调整 UITableView 的高度? [英] How do I resize the UITableView's height dynamically?

查看:23
本文介绍了如何动态调整 UITableView 的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我想在它处于编辑模式时调整表格视图的高度,而不是在它不处于编辑模式时(以便为表格视图下方的编辑控件腾出空间)

In my app, I would like to resize the tableview's height when it's in edit mode vs when it's not (in order to make room for editing controls below the table view)

这应该怎么做?

推荐答案

我发现当你在另一个视图中有一个浮动表时,操纵bounds"属性会导致一些意外的行为.有时表格在增加高度时会向上扩展,即使原点仍然是 0,0.

I found that manipulating the "bounds" property can result in some unexpected behavior when you have a floating table inside another view. Sometimes the table expands upward when increasing the height, even though the origin is still 0,0.

frame"属性可能更有效:

The "frame" property might be more effective:

CGRect tvframe = [tableView frame];
[tableView setFrame:CGRectMake(tvframe.origin.x, 
                                tvframe.origin.y, 
                                tvframe.size.width, 
                                tvframe.size.height + 20)];

这篇关于如何动态调整 UITableView 的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆