1
votes

I have been having trouble trying to drag a UIView that has a UIScrollView within it. The UIView drags up from the bottom of the screen, when it has hit the top you can use the UIScrollView inside it. When the user scrolls to the top of the UIScrollView, the UIView should drag down with their finger.

It should work like the Google Maps popup when you click a pin.

Update: I can get the dragging up of the UIView working (touchesMoved) that changes the Y value. The main functionality I am having problems with is the dragging down of the UIView when the user touches inside the UIScrollView. I want the user to still be able to drag the scrollview as normal until it reaches the top at which point the dragging action should then move the parent UIView down off the screen.

Update 2: This is the code you suggested to turn off the user interaction:

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if(scrollView.contentOffset.y<=0){
        scrollView.userInteractionEnabled = NO;
    }else{
        scrollView.userInteractionEnabled = YES;
    }
}
1
This question doesn't have one answer. It is a full feature. Make your question more specific please. Just for the sake of answering, you will need to make the view draggable by finger which means adding Gesture recognisers or overriding touchesBegun, touchesEnded, touchesCanceled and touchesMoved, on the view itself. Then you will need logic that connects the scroll view to the view and tells it when to take the touches' ownership. Can you please make your question a bit more specific so that we can help you? ThanksL_Sonic

1 Answers

2
votes

Most apps handle this scenario by using the UIScrollViewDelegate method scrollViewDidScroll.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    // check the scrollView.contentOffset.y to see if you 
    // have reached the top of the scroll view.
}

You can then check the contentOffset and continue with your dragging code the way you want.