在滚动UITableview时如何更改UIView的位置

时间:2014-08-16 18:52:07

标签: ios objective-c uiview uiscrollview

我有一个uiview,我想在向下滚动并向上滚动桌面时隐藏和显示,

这是我到目前为止所做的:

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    if ([scrollView.panGestureRecognizer translationInView:scrollView.superview].y > 0) {
        NSLog(@"moving up");
    } else {
        scrollingUp = false;
        NSLog(@"moving down");
        [self pushUpsearchView];
    }
}

pushUpsearchView方法:

-(void)pushUpsearchView{
    [UIView animateWithDuration:0.3 animations:^{
        CGRect frame = self.mysearchView.frame;
        frame.origin.x = self.mysearchView.frame.origin.x;
        frame.origin.y =   100;
        self.mysearchView.frame = frame;
        self.mysearchView.frame = frame;
    } completion:^(BOOL finished){
        NSLog(@"Finished animating!");
    }];
}

但这就是我最终的结果:

For some weird reason it duplicates it!

但是,当我从[self pushUpsearchView]方法移除scrollViewWillBeginDragging并将其放入我的viewdidload方法时,它可以正常运行而不会重复它只是更改其位置

0 个答案:

没有答案