Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 增加TableView标题的大小_Iphone_Ios_Uitableview_Uisearchbar - Fatal编程技术网

Iphone 增加TableView标题的大小

Iphone 增加TableView标题的大小,iphone,ios,uitableview,uisearchbar,Iphone,Ios,Uitableview,Uisearchbar,使用故事板,我制作了以下UITableViewController: 好的,当我开始搜索时,在搜索栏shouldbeginediting:中,我将隐藏导航栏并显示范围栏: - (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar { [self.mySearchBar setShowsScopeBar:YES]; [self.mySearchBar sizeToFit]; [self.mySearchBar

使用故事板,我制作了以下
UITableViewController

好的,当我开始搜索时,在
搜索栏shouldbeginediting:
中,我将隐藏导航栏并显示范围栏:

- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar {
    [self.mySearchBar setShowsScopeBar:YES];
    [self.mySearchBar sizeToFit];
    [self.mySearchBar setShowsCancelButton:YES animated:YES];
    [self.navigationController setNavigationBarHidden:YES animated:YES];

    return YES;
}

但表的第一个单元格隐藏在范围栏后面。我想我需要增加表格标题,但是我怎么做呢?或者有其他方法来修复它?

UITableViewDelegate有一个方法可以执行此操作:

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    //return height as a float here
}
以适当的高度在学员身上实现这一点

或者,如果条形图隐藏了单元格的顶部,则可能需要在屏幕上向下移动表格视图,方法是更改其框架,如下所示:

CGRect newFrame = tableView.frame;
newFrame.origin.y += 45; //or whatever number of pixels you want to move it down by
tableView.frame = newFrame;

在回答我自己的问题时,再看一看,我发现了一个似乎最正确的解决方案,那就是使用
UISearchDisplayController
。以下是我遵循的教程:

使用这种方式,他隐藏导航栏并显示范围,而不需要额外的代码,也不存在隐藏第一个单元格的问题