UIScrollViewDelegate scrollViewWillEndDragging:withVelocity:targetContentOffset getting called with pagingEnabled = YES
Asked Answered
W

0

9

According to Apples documentation (and numerous other places), UIScrollViewDelegate:scrollViewWillEndDragging:withVelocity:targetContentOffset does not get called if UIScrollView.pagingEnabled is set to YES. On iOS6 this appears to be true, however, on iOS7 it is ALWAYS getting called for me, no matter what pagingEnabled is set to.

Here's a simple test view controller:

@interface ViewController ()
<UIScrollViewDelegate>
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end

@implementation ViewController

- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
    NSLog(@"%d", scrollView.pagingEnabled);
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self loadHTML];
    [self configureWebView];
}

- (void)loadHTML
{
    NSString* htmlPath = [[NSBundle mainBundle] pathForResource:@"htmlContent" ofType:@"html"];
    NSString* htmlString = [NSString stringWithContentsOfFile:htmlPath encoding:NSUTF8StringEncoding error:nil];
    [_webView loadHTMLString:htmlString baseURL:nil];
}

- (void)configureWebView
{
    [_webView.scrollView setDelegate:self];
    _webView.scrollView.pagingEnabled = YES;
}

@end

In iOS7, if pagingEnabled == YES, the NSLog in scrollViewWillEndDragging prints 1, if it's set to NO, it prints 0.

In iOS6, when pagingEnabled == YES, console output is:

Stop offset can not be modified for paging scroll views

When it is NO, output is 0.

Is anyone else getting this? Does anyone know if this is supposed to be this way in iOS7? The documentation hasn't changed, so I'm assuming not, but I thought I'd ask you all before filing a bug report with Apple and adding checks for pagingEnabled in all my delegate calls.

Wilmerwilmette answered 1/11, 2013 at 17:38 Comment(2)
I agree, that it is a bug, but it is was very useful for me one time.Teresaterese
It does get called for me (iOs 8+), and I actually find it useful, for instance when I was working on a image gallery I used it to make it scroll further in the gallery when velocity was big by increasing targetContentOffset depending on velocityIntracranial

© 2022 - 2024 — McMap. All rights reserved.