1. 程式人生 > >UIScrollView滾動獲取停止點及禁止慣性滾動

UIScrollView滾動獲取停止點及禁止慣性滾動

UIScrollView實現Delegate

#pragma mark - UIScrollViewDelegate

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{    
    NSLog(@"scrollViewDidEndDecelerating:");
    
    /*
     獲取當前scrollView的停止座標
     */
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    NSLog(@"scrollViewWillBeginDragging:");
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    NSLog(@"scrollViewDidEndDragging:");
    
    if (!decelerate)
    {
        /*
         獲取當前scrollView的停止座標
         */
    }
    
    /*
     禁止慣性滾動
     */
//    if (decelerate)
//    {
//        dispatch_async(dispatch_get_main_queue(), ^{
//            [scrollView setContentOffset:scrollView.contentOffset animated:NO];
//        }); 
//    }
}