UISearchBar 添加到视图后,UITableView 不会弹跳/滚动
我有一个充满数据行的 UITableView
。只有3、4行数据没有到达屏幕底部,但上下滑动时表格仍然按预期垂直弹起。在 Interface Builder 中将 UISearchBar
添加到 UITableView
的顶行/标题后,表格最初不再弹跳。但是,在导航到不同的视图并返回到同一视图后,表格再次弹跳。为什么 UITableView
在视图最初加载时不弹起,以及如何使其弹起?
- (void)viewWillAppear:(BOOL)animated {
[table reloadData];
[super viewWillAppear:animated];
}
- (void)viewDidLoad {
...
[table reloadData];
[super viewDidLoad];
}
- (void)viewDidUnload {
...
self.table = nil;
[super viewDidUnload];
}
I have a UITableView
filled with rows of data. There are only 3 or 4 rows of data which do not reach the bottom of the screen, but the table still bounces vertically as expected when swiping up and down. After adding a UISearchBar
to the top row/header of the UITableView
in Interface Builder, the table no longer bounces initially. However, after navigating to a different view and returning to the same view, the table once again bounces. Why does the UITableView
not bounce when the view is initially loaded, and how do I make it so that it does bounce?
- (void)viewWillAppear:(BOOL)animated {
[table reloadData];
[super viewWillAppear:animated];
}
- (void)viewDidLoad {
...
[table reloadData];
[super viewDidLoad];
}
- (void)viewDidUnload {
...
self.table = nil;
[super viewDidUnload];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过实现
关键是在
viewDidLoad
方法中添加self.tableView.bounces = YES
。I was able to solve this problem by implementing the answer on this question.
The key was to add
self.tableView.bounces = YES
in theviewDidLoad
method.