2012-03-27 182 views
0

用故事板,我做了这个UITableViewController增加大小

enter image description here

好吧,当我开始搜索,在searchBarShouldBeginEditing:我会隐藏导航栏和显示范围栏:

- (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; 
} 

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

回答

1

的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;