我遇到关于UISearchDisplayController
的表视图,只发生在IOS 6我刚刚创建我的tableview在笔尖文件,然后这个奇怪的错误编程方式添加一个搜索栏它上面和搜索显示控制器的表视图筛选数据:搜索显示控制器结果的tableview不能在滚动的iOS 6
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.mpSearchBar = [[MPSearchBar alloc] initWithFrame:CGRectMake(0, 0, 250, 44)];
self.mpSearchBar.placeholder [email protected]"Card Search";
self.searchController = [[UISearchDisplayController alloc] initWithSearchBar:self.mpSearchBar contentsController:self];
self.searchController.delegate = self;
self.searchController.searchResultsDataSource = self;
self.searchController.searchResultsDelegate = self;
self.resultTableView.delegate = self;
self.resultTableView.dataSource = self;
[self.resultTableView reloadData];
}
当我第一次进入在搜索栏中一些查询,搜索显示控制器对数据进行过滤和控制的结果表视图正常工作。然而,当我点击搜索栏清除按钮,然后输入别的东西,它包含了一套新的不能长期滚动的过滤数据的结果表视图。有什么奇怪的是,当我尝试登录该frame
和表格视图contentSize
,内容大小高度比框架的高度较大,因为它应该是:
- (void)searchDisplayController:(UISearchDisplayController *)controller willShowSearchResultsTableView:(UITableView *)tableView {
tableView.scrollIndicatorInsets = UIEdgeInsetsZero;
tableView.contentInset = UIEdgeInsetsZero;
[tableView hideEmptySeparators];
if (IOS_EQUAL_OR_NEWER_THAN_7){
tableView.separatorInset = UIEdgeInsetsZero;
}
NSLog(@"Frame height %f, Content height %f", tableView.frameHeight, tableView.contentSize.height);
}
这是我从一开始日志:
框架高度504.000000,内容高度1402.000000
这只是发生时,我在iOS 6设备上测试,我不知道如何调试这个问题。
请建议和感谢。
什么,究竟是newContentSize?你如何确定正确的尺寸? – Gargoyle
@Gargoyle假设你的表视图具有普通样式,你可以使用你的细胞的高度和你的表视图细胞总数含量的大小。这就是我获得内容大小的方式。 –