Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.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
Ios 滚动tableview时隐藏NavigationControllerBar_Ios_Objective C_Iphone_Uitableview_Uinavigationbar - Fatal编程技术网

Ios 滚动tableview时隐藏NavigationControllerBar

Ios 滚动tableview时隐藏NavigationControllerBar,ios,objective-c,iphone,uitableview,uinavigationbar,Ios,Objective C,Iphone,Uitableview,Uinavigationbar,我已经实现了一个UITableViewController 第一部分是一个大图像。当视图控制器最初出现时,我将导航栏设置为半透明 当tableview向下滚动时,navigationBar.translucent设置为NO,tableview内容框向上移动,以使第一部分脱离屏幕。我在scrollview委托中实现了移动: -(void)scrollViewDidScroll:(UIScrollView *)scrollView 当向上滚动tableview时,导航再次变为半透明,tablevi

我已经实现了一个UITableViewController

第一部分是一个大图像。当视图控制器最初出现时,我将导航栏设置为半透明

当tableview向下滚动时,navigationBar.translucent设置为NO,tableview内容框向上移动,以使第一部分脱离屏幕。我在scrollview委托中实现了移动:

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
当向上滚动tableview时,导航再次变为半透明,tableview框架将恢复

问题是,当scrollview代理捕捉到滚动手势时。一旦tableview和navigationBar开始动画。tableview的滚动动作停止。因此,如果我想将tableview滚动到底部,我必须滚动两次,第一次设置帧的动画,然后再次滚动,我认为它可以得到增强

这是代码

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == _subTable) {
    NSIndexPath * indexPath ;
    CGFloat offset = scrollView.contentOffset.y;
    if ((offset - currentOffset)>40) {

        if (!scrollAnimate) {
            self.navigationController.navigationBar.translucent = NO;
            [UIView animateWithDuration:0.5 animations:^{
                [_mainTable setContentOffset:CGPointMake(0, headHeight) animated:YES];
                [_subTable setFrame:CGRectMake(CGRectGetWidth(self.menuTable.frame)                                                                                                                                                                                                                                                                                                                                                                                              , 0, kScreen_Width/3.5*2.5, kScreen_Height-schedualHeight-48)];
                [_mainTable setFrame:CGRectMake(0, 0, kScreen_Width, _mainTable.frame.size.height+headHeight)];
                [_menuTable setFrame: CGRectMake(0, 0, kScreen_Width/3.5, _mainTable.frame.size.height+headHeight-48)];
            }];

            if (CGRectGetMaxY(_checkOutBar.frame)!= kScreen_Height-44)
            {
                [_checkOutBar setFrame:CGRectOffset(_checkOutBar.frame, 0, -44)];
            }
            scrollAnimate = !scrollAnimate;
            frameOffset = !frameOffset;

            [_mainTable reloadData];
            _checkOutBar.tag = 1000;
        }

    }
    else if((offset - currentOffset)<-40)
    {

        if (scrollAnimate) {
            self.navigationController.navigationBar.translucent = YES;
            [UIView animateWithDuration:0.5 animations:^{
                [_mainTable setFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height+self.navigationController.navigationBar.frame.size.height+headHeight)];
                [self.mainTable setFrame:CGRectOffset(_mainTable.frame, 0, -(self.navigationController.navigationBar.frame.size.height))];
                [_subTable setFrame:CGRectMake(CGRectGetWidth(self.menuTable.frame), 0, kScreen_Width/3.5*2.5, tableHeight)];
                [_menuTable setFrame:CGRectMake(0, 0, kScreen_Width/3.5, tableHeight)];
            }];
            scrollAnimate = !scrollAnimate;
            frameOffset = !frameOffset;

            [_mainTable reloadData];
            if (CGRectGetMaxY(_checkOutBar.frame)!= kScreen_Height) {
                [_checkOutBar setFrame:CGRectOffset(_checkOutBar.frame, 0, 44)];
            }
            _checkOutBar.tag = 2000;
        }
    }
    if ((offset - currentOffset)>0)
    {
        indexPath = [[_subTable indexPathsForVisibleRows]lastObject];
    }
    else
    {

        indexPath = [[_subTable indexPathsForVisibleRows]firstObject];
    }

    if (indexPath) {
        if (indexPath.row == 0) {
            selected = indexPath.section;
                [_menuTable reloadData];
            }
        }

        currentOffset = offset;
    }
}
-(无效)scrollViewDidScroll:(UIScrollView*)scrollView
{
如果(滚动视图==\u子表){
nsindepath*indepath;
CGFloat offset=scrollView.contentOffset.y;
如果((偏移-电流偏移)>40){
如果(!滚动动画){
self.navigationController.navigationBar.translucent=否;
[UIView animateWithDuration:0.5动画:^{
[_MainTableSetContentOffset:CGPointMake(0,头高)动画:是];
[\u子表setFrame:CGRectMake(CGRectGetWidth(self.menuTable.frame)                                                                                                                                                                                                                                                                                                                                                             ,0,k屏幕(宽度/3.5*2.5,k屏幕(高度-48)];
[_maintablesetframe:CGRectMake(0,0,k屏幕宽度,_mainTable.frame.size.height+headHeight)];
[_menutablesetframe:CGRectMake(0,0,k屏幕宽度/3.5,_mainTable.frame.size.height+headHeight-48)];
}];
如果(CGRectGetMaxY(_checkOutBar.frame)!=kScreen_Height-44)
{
[_checkoutbarsetframe:CGRectOffset(_checkOutBar.frame,0,-44)];
}
滚动动画=!滚动动画;
frameOffset=!frameOffset;
[_maintablereloaddata];
_checkOutBar.tag=1000;
}
}
否则如果((偏移-当前偏移)0)
{
indexPath=[[u子表indexPathsForVisibleRows]lastObject];
}
其他的
{
indexPath=[[u子表indexPathsForVisibleRows]firstObject];
}
if(indexath){
if(indexPath.row==0){
selected=indexath.section;
[_menutablereloaddata];
}
}
currentOffset=偏移量;
}
}

苹果文档中的
。设置NavigationController。hidesBarsOnSwipe=是; hidesBarsOnSwipe 财产 一个布尔值,指示导航栏是否在响应滑动手势时隐藏其栏

声明:
斯威夫特:

目标C:

@property(nonatomic, readwrite, assign) BOOL hidesBarsOnSwipe
讨论:

当此属性设置为“是”时,向上滑动将隐藏导航栏和工具栏。向下轻扫将再次显示两个条。如果工具栏中没有任何项目,则即使在刷卡后,它仍保持可见。此属性的默认值为
NO

可用性:
iOS 8.0及更高版本提供。

为什么您的问题标题与问题内容不同?
@property(nonatomic, readwrite, assign) BOOL hidesBarsOnSwipe