First I created my regular UITextView, set the delegate and implemented the delegate methods:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (scrollView.isDecelerating) {
NSLog(@" ... restarting");
} else {
NSLog(@"Scroll will begin");
}
}
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(CGPoint *)targetContentOffset
{
NSLog(@"will end dragging: velocity: %f", velocity.y);
}
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
if (decelerate) {
} else {
NSLog(@"Scroll did end (Dragging)");
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
NSLog(@"Scroll did end (Decelerating)");
}
So if I ...
scroll without deceleration I get:
Scroll will begin
will end dragging: velocity: 0.000000
Scroll did end (Dragging)
scroll with deceleration I get:
Scroll will begin
will end dragging: velocity: 0.321089
Scroll did end (Decelerating)
start scrolling with deceleration and while its decelerating do another scrolling without deceleration I get:
Scroll will begin
will end dragging: velocity: 1.094134
... restarting
will end dragging: velocity: 0.000000
Scroll did end (Dragging)
start scrolling with desceleration and while its decelerating do another scrolling with deceleration I get:
Scroll will begin
will end dragging: velocity: 1.995404
... restarting
will end dragging: velocity: 0.442658
Scroll did end (Decelerating)
Everything goes as expected :)
Why do I need
scrollViewWillEndDragging:withVelocity:targetContentOffset: ?.
This is my little finding: If that method is **not** implement and then I ...start scrolling with deceleration and while its decelerating do another scrolling without deceleration I get :
Scroll will begin
will end dragging: velocity: 1.094134
... restarting
will end dragging: velocity: 0.000000
Scroll did end (Dragging)
Scroll did end (Decelerating)
Huh?? The textview ended dragging and just after decelerating? Did I find a bug?
So, in order to get notified only once when the text did end scrolling I need to implement
scrollViewWillEndDragging:withVelocity:targetContentOffset: ??
??
I hope I am not missing something.
In the mean time I uploaded a sample project that show the issue here.
0 comments :
Post a Comment