Latest 0.0.1
Homepage https://github.com/Wayne2Wen/WWViewScrollObserve
License MIT
Platforms ios 8.0, requires ARC
Dependencies ReactiveObjC
Frameworks UIKit
Authors

License MIT 
CocoaPods 
Support 

You can get view’s visible rect and observe whether it is displaying on the screen when the scroll view stops scrolling.
Listen for all the scroll methods in UIKit that have animation in them.

Scroll begin trigger methods

// delegate method
- (void)scrollViewDidScroll:(UIScrollView *)scrollView;

// instance method: only animated == YES
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;

- (void)scrollRectToVisible:(CGRect)rect animated:(BOOL)animated; 

Scroll end trigger methods

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;

- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;

- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;

setContentOffset: and other methods without scrolling animation(setContentOffset:animated: and scrollRectToVisible:animated:, parameter animated is NO) are not listened for, you can use [scrollView ww_postScrollBegin] notify view is scrolling, and use [scrollView ww_postScrollEnd] notify view did end scroll

How To Use

Add observe

[scrollView ww_registerObserve];

Observe operation

view.ww_visibleHandler = ^(CGRect viewRect, CGRect containerRect, BOOL stop) {
    NSString *stopStr = stop ? @"🎈End" : @"🌲Begin";
    NSString *str = [NSString stringWithFormat:@"%zd-%@", self.index, stopStr];
    NSLog(@"%@ScrollnViewRect:%@, nContainerRect:%@", str, NSStringFromCGRect(viewRect), NSStringFromCGRect(containerRect));
};

Remove observe

[scrollView ww_unregisterObserveWithHandler:^(BOOL isRegistedBefore) {
    // need to do something when unregister  
}];

Installation

platform :ios, '8.0'
pod 'WWViewScrollObserve'

Dependency

Depend on ReactiveObjC. Before get started,you can run the demo WWViewScrollObserveDemo

Latest podspec

{
    "name": "WWViewScrollObserve",
    "summary": "You can get view's visible rect and observe whether it is displaying on the screen when the scroll view stops scrolling.",
    "version": "0.0.1",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Wayne2Wen": "[email protected]"
    },
    "homepage": "https://github.com/Wayne2Wen/WWViewScrollObserve",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/Wayne2Wen/WWViewScrollObserve.git",
        "tag": "0.0.1"
    },
    "requires_arc": true,
    "source_files": "Srcs/**/*{h,m}",
    "public_header_files": "Srcs/Public/*.{h}",
    "frameworks": "UIKit",
    "dependencies": {
        "ReactiveObjC": [
            "~> 3.1.0"
        ]
    }
}

Pin It on Pinterest

Share This