Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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 UIView在开始时跳下_Ios_Objective C_Uiview - Fatal编程技术网

Ios UIView在开始时跳下

Ios UIView在开始时跳下,ios,objective-c,uiview,Ios,Objective C,Uiview,我需要更改ui视图在tableview滚动条上的位置。当我在动画块中更改UIView的帧大小时,它会下降,然后移动到正确的位置。请看我的密码 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { CGPoint scrollVelocity = [_collectionViewLeaderboard.panGestureRecognizer velocityInView:_collectionViewLeaderboard.superv

我需要更改
ui视图
tableview
滚动条上的位置。当我在动画块中更改
UIView
的帧大小时,它会下降,然后移动到正确的位置。请看我的密码

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGPoint scrollVelocity = [_collectionViewLeaderboard.panGestureRecognizer velocityInView:_collectionViewLeaderboard.superview];
if (scrollVelocity.y > 0.0f){
    NSLog(@"going down");
    [UIView animateWithDuration:0.3f
                              animations:^ {

                                  _headerview.frame = CGRectMake(0, 0, _headerview.frame.size.width, _headerview.frame.size.height);

                                  _headerviewSecond.frame = CGRectMake(0, _headerview.frame.size.height, _headerviewSecond.frame.size.width, _headerviewSecond.frame.size.height);

                                  self.collectionViewLeaderboard.frame = CGRectMake(self.view.frame.origin.x, _headerviewSecond.frame.size.height+_headerview.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);

                                  frameconditon = _headerview.frame;

                              } completion:^ (BOOL completed) {

                              }];

}
else if (scrollVelocity.y < 0.0f){
    NSLog(@"going up");

    //CGAffineTransform transform = CGAffineTransformMake(1, 0, 0, 1, _headerview.frame.origin.x, _headerview.frame.origin.y);
        [UIView animateWithDuration:5.0 animations:^{
            NSLog(@"test");


            _headerview.frame = CGRectMake(0, -(_headerview.frame.size.height), _headerview.frame.size.width, _headerview.frame.size.height);

            _headerviewSecond.frame = CGRectMake(0, (_headerview.frame.size.height)-40, _headerviewSecond.frame.size.width, _headerviewSecond.frame.size.height);

        } completion:^(BOOL finished) {

        }];


         self.collectionViewLeaderboard.frame = CGRectMake(self.view.frame.origin.x, _headerviewSecond.frame.size.height, self.view.frame.size.width, self.view.frame.size.height);

 }
 }
-(无效)scrollViewDidScroll:(UIScrollView*)scrollView{
CGPoint scrollVelocity=[\u CollectionViewLeadboard.pangestureRecognitor Velocity视图:\u CollectionViewLeadboard.superview];
如果(scrollVelocity.y>0.0f){
NSLog(@“下降”);
[UIView动画宽度:0.3f
动画:^{
_headerview.frame=CGRectMake(0,0,_headerview.frame.size.width,_headerview.frame.size.height);
_headerviewSecond.frame=CGRectMake(0,_headerviewSecond.frame.size.height,_headerviewSecond.frame.size.width,_headerviewSecond.frame.size.height);
self.collectionViewLeadboard.frame=CGRectMake(self.view.frame.origin.x,_headerviewSecond.frame.size.height+_headerview.frame.size.height,self.view.frame.size.width,self.view.frame.size.height);
frameconditon=\u headerview.frame;
}完成:^(BOOL已完成){
}];
}
否则如果(滚动速度y<0.0f){
NSLog(@“上升”);
//CGAffineTransform transform=CGAffineTransformMake(1,0,0,1,_headerview.frame.origin.x,_headerview.frame.origin.y);
[UIView animateWithDuration:5.0动画:^{
NSLog(“测试”);
_headerview.frame=CGRectMake(0,-(_headerview.frame.size.height),_headerview.frame.size.width,_headerview.frame.size.height);
_headerviewSecond.frame=CGRectMake(0,(_-headerviewSecond.frame.size.height)-40,_-headerviewSecond.frame.size.width,_-headerviewSecond.frame.size.height);
}完成:^(布尔完成){
}];
self.collectionViewLeadboard.frame=CGRectMake(self.view.frame.origin.x,_headerviewSecond.frame.size.height,self.view.frame.size.width,self.view.frame.size.height);
}
}

headerview
应该移动到视图的顶部,它可以工作,但当我第一次运行它时,它会下降并返回到正确的位置。如何在滚动时更改约束。

对于基于约束的视图,请尝试通过使用出口更改约束常量属性来设置动画