如何隐藏UITableView上的headView部分?

时间:2013-04-23 02:31:25

标签: iphone ios objective-c objective-c-blocks

我想在触摸时隐藏导航栏和标签栏并移动uitableview,吹码: 来自viewForHeaderInSection的_headView没问题。 但有时在阻止执行后,_headView可见

if(_headView)
    _headView.hidden = YES; //
[UIView animateWithDuration:0.5 animations:^{
    scrollView.frame = rect;
    _vc.navigationController.navigationBar.top -= navigationBarHeight;
    tabView.top =  SCREEN_HEIGHT;

} completion:^(BOOL finished) {
}];

如果我将隐藏代码移动到完成块,它运行正常,但在0.5秒后隐藏,这是缓慢的。

[UIView animateWithDuration:0.5 animations:^{
    scrollView.frame = rect;
    _vc.navigationController.navigationBar.top -= navigationBarHeight;
    tabView.top =  SCREEN_HEIGHT;

} completion:^(BOOL finished) {
    if(_headView)
        _headView.hidden = YES;  //Delay after 0.5s.
}];

请帮助我,谢谢。

1 个答案:

答案 0 :(得分:0)

我们为UITableView

的部分设置高度设置了委托方法
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

为此隐藏标题,只返回0。