简体   繁体   English

如何在ViewController上调整TableView的大小

[英]How to resizing tableview on viewcontroller

I have a viewcontroller where I added a tableview into it using the storyboard. 我有一个视图控制器,在这里使用情节提要向其中添加了一个表视图。 The rows are displaying labels of search filters where user tap on the row and a picker will appear at the bottom of the view. 这些行显示搜索过滤器的标签,用户在其中点击该行,并且选择器将出现在视图的底部。 I have about 10 rows so when user taps on the last few rows, the data picker blocks of the row. 我大约有10行,所以当用户点击最后几行时,该行的数据选择器块就会出现。 How do I resize the table (made an IBoutlet and called it myTable) and show the selected row above the data picker? 如何调整表的大小(制作一个IBoutlet并将其命名为myTable),并在数据选择器上方显示所选行?

I tried putting this on the 'didSelectRowAtIndexPath' section but not working 我尝试将其放在“ didSelectRowAtIndexPath”部分,但不起作用

[self.view addSubview:self.myTable];

self.myTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 148, 320, 10)];

Hope someone can help out on this. 希望有人能帮上忙。

Try this: 尝试这个:

[self.view addSubview:self.myTable];
self.myTable = [[UITableView alloc] initWithFrame:CGRectMake(0, 148, 320, 10)];

[tableView beginUpdates];
[tableView endUpdates];

Essentially, your goal is to refresh the table view. 本质上,您的目标是刷新表视图。 If that doesn't work, you could even try: 如果那不起作用,您甚至可以尝试:

[self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];

or: 要么:

[tableView reloadData];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM