Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
Hi. Is there a way to stop the scrolling in a uiscrollview ? I want to stop the scrollview when the user touches/drags a zoomslider. If I don't and the user drag the scrollview and then start zooming it jumps around like crazy.
Do you need the user to be able to zoom, or interact with the scrollview?
If not, you can set userInteractionEnabled to NO.
Yes, I need the user to be able to zoom & drag the scrollview, but as soon as he touches the slider I want the moving/zooming to stop and to set the zoomvalue from the slider by calling setZoomScale:slider.value. I tried to set the scrollEnabled to NO when the user touches the slider and back to YES when the user release the slider, but the scrollEnabled doesn't seem to have any impact before the scrollview has stopped moving.
What about creating an IBAction that checks if the slider's value has changed, and if it is, set userInteractionEnable to NO, and when the user lifts the finger, set it back to YES?
// If the touch is inside the view, let the view handle it if ([v pointInside:convertedPoint withEvent:event]) { return v; } else { return [super hitTest:point withEvent:event]; } }
// If the touch is inside the view, let the view handle it if ([v pointInside:convertedPoint withEvent:event]) { return v; } else { return [super hitTest:point withEvent:event]; } }
with your slider's tag is 999 with this the scroll view will not process your touch but release it to your slider Good luck!
The slider is not in the scrollview so thats not the problem. I just want to send a call to the slideview so it stop scrolling instantly. I tried to set userInteractionEnabled=NO when the user touches the slider, but that doesn't stop the scrolling. Sorry for my bad explaining :).
// If the touch is inside the view, let the view handle it if ([v pointInside:convertedPoint withEvent:event]) { return v; } else { return [super hitTest:point withEvent:event]; } }
I had a similar situation where I needed to tell a UIScrollView to stop scrolling and had a crazy idea that seems to work. In my testing so far, the behavior seems identical to what happens when a user touches a view that is scrolling - it stops immediately. It also seems to handle bounces the same way - the view stops scrolling and immediately goes to the edge of the content.
Try the following code. If you wanted to, you could also extend the UIScrollView class and include this as a function:
//Stop the scrolling in a UIScrollView by telling the view to scroll to its current offset position //(or to scroll to the edge of the view if the current offset position is outside of the content //area due to a "bounce")
float x = fmin(fmax(minX, currentX), maxX); float y = fmin(fmax(minY, currentY), maxY);
//Tell the view to scroll to the new position. Note that animated must be YES in order to stop //any current scrolling animations. [myScrollView setContentOffset:CGPointMake(x, y) animated:YES];
NOTE: In order to get the fmin and fmax functions to work, you will need to #import
I had a similar situation where I needed to tell a UIScrollView to stop scrolling and had a crazy idea that seems to work. In my testing so far, the behavior seems identical to what happens when a user touches a view that is scrolling - it stops immediately. It also seems to handle bounces the same way - the view stops scrolling and immediately goes to the edge of the content.
Try the following code. If you wanted to, you could also extend the UIScrollView class and include this as a function:
//Stop the scrolling in a UIScrollView by telling the view to scroll to its current offset position //(or to scroll to the edge of the view if the current offset position is outside of the content //area due to a "bounce")
float x = fmin(fmax(minX, currentX), maxX); float y = fmin(fmax(minY, currentY), maxY);
//Tell the view to scroll to the new position. Note that animated must be YES in order to stop //any current scrolling animations. [myScrollView setContentOffset:CGPointMake(x, y) animated:YES];
NOTE: In order to get the fmin and fmax functions to work, you will need to #import
I just ran into a situation where I needed my tableview to stop scrolling in order to load another list of data to display...and this works like a charm.
Replies
Hope that helps. :)
Cheese C
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeMulti Protractor
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeIf not, you can set userInteractionEnabled to NO.
Cheese C
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI tried to set the scrollEnabled to NO when the user touches the slider and back to YES when the user release the slider, but the scrollEnabled doesn't seem to have any impact before the scrollview has stopped moving.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeCheese C
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeNow please try this
with your slider's tag is 999
with this the scroll view will not process your touch but release it to your slider
Good luck!
Multi Protractor
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI tried to set userInteractionEnabled=NO when the user touches the slider, but that doesn't stop the scrolling.
Sorry for my bad explaining :).
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI had a similar situation where I needed to tell a UIScrollView to stop scrolling and had a crazy idea that seems to work. In my testing so far, the behavior seems identical to what happens when a user touches a view that is scrolling - it stops immediately. It also seems to handle bounces the same way - the view stops scrolling and immediately goes to the edge of the content.
Try the following code. If you wanted to, you could also extend the UIScrollView class and include this as a function:
//Stop the scrolling in a UIScrollView by telling the view to scroll to its current offset position
//(or to scroll to the edge of the view if the current offset position is outside of the content
//area due to a "bounce")
float currentX = myScrollView.contentOffset.x;
float minX = 0;
float maxX = fmax(0, myScrollView.contentSize.width - myScrollView.frame.size.width);
float currentY = myScrollView.contentOffset.y;
float minY = 0;
float maxY = fmax(0, myScrollView.contentSize.height - myScrollView.frame.size.height);
float x = fmin(fmax(minX, currentX), maxX);
float y = fmin(fmax(minY, currentY), maxY);
//Tell the view to scroll to the new position. Note that animated must be YES in order to stop
//any current scrolling animations.
[myScrollView setContentOffset:CGPointMake(x, y) animated:YES];
NOTE: In order to get the fmin and fmax functions to work, you will need to #import
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks!!
[IMG]http://farm5.static.flickr.com/4088/5031188912_c8ab4cd97c.jpg[/IMG]
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome