更改UITableviews的高度以使其内容适合xcode吗? [英] Change UITableviews height to fit its content in xcode?
问题描述
我需要制作 UITaableView
使其适合其内容.我正在将数组数据加载到 UITableView
中.但是当我固定了一些静态大小时,即使项目较少,它还是显示多余的空间.因此,我需要将动态高度设置为 UITableView
,但无法实现..
I need to make UITaableView
to fit its content.I m loading array data in UITableView
.But when I fixed some static size ,eventhough the items are less it is showing the extra space.So I need to make dynamic height to UITableView
but could not achieve it ..
autocompleteTableView = [[UITableView alloc] initWithFrame:CGRectMake(10, 140, 200, self.autocompleteTableView.contentSize.height) style:UITableViewStyleGrouped];
autocompleteTableView.delegate = self;
autocompleteTableView.dataSource = self;
autocompleteTableView.scrollEnabled = YES;
[self.view addSubview:autocompleteTableView];
当我写这篇文章时,我看不到TableView本身.如何获得它?
When I write this I could not see the TableView itself..How can I get it ?
推荐答案
用于 动态表格视图高度
.您需要应用动态框架.
For dynamic tableview height
. You need to apply dynamic frame.
例如,
myTable.frame = CGRectMake(x,y,w,[row count] * 44);
其中44是表格视图单元格的默认大小
Where 44 is default size of tableview cell
因此,您需要知道每个像元的高度,然后才能应用它.
Thus, you need to know each cell height, In order to apply this.
享受编程
这篇关于更改UITableviews的高度以使其内容适合xcode吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!