根据动态输入自动调整表格视图中的单元格大小
Auto resize a cell in tableview based on dynamic input
如何根据用户输入自动调整表格视图中单元格的大小。因此,如果用户输入大量单词,单元格会按顺序展开,以便标签可以展开,所有文本都可以换行和适合。
在 iPhone 提醒应用程序中具体是如何完成的。
我想你需要的是这个 -
tableView.estimatedRowHeight = 100
//You can put anything in place of 100.
tableView.rowHeight = UITableViewAutomaticDimension
希望对您有所帮助
基本实现是在所有四个方面添加约束,即顶部、底部、前导和尾随。
并在 viewDidLoad() 中,将 TableViewHeight 设置为 UITableViewAutomaticDimension
- (void)viewDidLoad
{
...
...
self.tableView.estimatedRowHeight = 50.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
/*To hide separator from empty space at bottom*/
[[self tableView] setTableFooterView:[UIView new]];
}
按照这个不错的教程,您将能够立即实现所需的功能
如何根据用户输入自动调整表格视图中单元格的大小。因此,如果用户输入大量单词,单元格会按顺序展开,以便标签可以展开,所有文本都可以换行和适合。
在 iPhone 提醒应用程序中具体是如何完成的。
我想你需要的是这个 -
tableView.estimatedRowHeight = 100
//You can put anything in place of 100.
tableView.rowHeight = UITableViewAutomaticDimension
希望对您有所帮助
基本实现是在所有四个方面添加约束,即顶部、底部、前导和尾随。
并在 viewDidLoad() 中,将 TableViewHeight 设置为 UITableViewAutomaticDimension
- (void)viewDidLoad
{
...
...
self.tableView.estimatedRowHeight = 50.0;
self.tableView.rowHeight = UITableViewAutomaticDimension;
/*To hide separator from empty space at bottom*/
[[self tableView] setTableFooterView:[UIView new]];
}
按照这个不错的教程,您将能够立即实现所需的功能