Iphone iOS中UITableView的UISearchDisplayController框架 我有一个UITable,它有一个UISearchDisplayController UITable小于屏幕的宽度(以280px的宽度为中心) 当我点击搜索栏时,UISearchDisplayController表格一直在屏幕的左侧 即使在更改UISearchDisplayController的表格框架时,我仍然得到相同的定位
我在这里设置框架:Iphone iOS中UITableView的UISearchDisplayController框架 我有一个UITable,它有一个UISearchDisplayController UITable小于屏幕的宽度(以280px的宽度为中心) 当我点击搜索栏时,UISearchDisplayController表格一直在屏幕的左侧 即使在更改UISearchDisplayController的表格框架时,我仍然得到相同的定位,iphone,ios,uisearchbar,uisearchdisplaycontroller,Iphone,Ios,Uisearchbar,Uisearchdisplaycontroller,我在这里设置框架: - (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView { tableView.backgroundColor = [UIColor colorWithRed:29.0/255.0 green:30.0/255.0 blue:32.0/255.0 alpha:1];
- (void)searchDisplayController:(UISearchDisplayController *)controller didLoadSearchResultsTableView:(UITableView *)tableView {
tableView.backgroundColor = [UIColor colorWithRed:29.0/255.0 green:30.0/255.0 blue:32.0/255.0 alpha:1];
tableView.rowHeight = self.myTable.rowHeight;
tableView.frame = myTable.frame;
NSLog(@"search table origin: %f",tableView.frame.origin.x);
}
更奇怪的是,当我在末尾记录搜索表的位置时,它显示为16。但是,它位于视图中的位置0
非常感谢您的帮助。我回答了自己的问题。需要在此委托方法中设置框架:
- (void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView {
tableView.frame = self.myTable.frame;
}
尝试以下简单方法:
//--Search display controller frame
- (void)searchDisplayController:(UISearchDisplayController *)controller didShowSearchResultsTableView:(UITableView *)tableView
{
CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
[tableView setFrame:CGRectMake(my_table.frame.origin.x, tableView.frame.origin.y, my_table.frame.size.width, my_table.frame.size.height)];
}
汤姆·斯威夫特的回答解决了我的问题:谢谢,我正要创建我自己的表格视图,因为我想把它稍微移到搜索栏下面,但找不到一个干净的方法。谢谢,它帮助了我,但至少留下了两个问题:旋转设备时,表格视图适合整个屏幕的宽度,而关闭动画很难看时,它再次闪烁到整个宽度。