Latest 0.1.0
Homepage https://github.com/ethanbing/YBScrollSuspendManage
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

YBScrollSuspendManage is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'YBScrollSuspendManage'

Usage

说明:适用于页面嵌套滚动,并且滚动到某个位置可以悬停滚动

1、主控制器初始化YBScrollSuspendManage

- (YBScrollSuspendManage *)suspendManage
{
    if (!_suspendManage) {
        _suspendManage = [YBScrollSuspendManage new];
        _suspendManage.delegate = self;
    }
    return _suspendManage;
}

2、在初始化子控制器时,把suspendManage传给子控制器

YBGridViewController * gridVC = [YBGridViewController new];
gridVC.yb_suspendManage = self.suspendManage;

3、在主控制器的scrollViewDidScroll:代理方法调用

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    YBBaseTabelViewController * tabelViewController = [self.bookmarkView currentViewController];
    //需要悬浮滚动的控制器
    [self.suspendManage mainScrollViewDidScroll:scrollView subScrollView:tabelViewController.tableView forHeaderMaxY:200];
}

4、子控制器的ScrollView激活多手势

//激活多手势
_tableView.yb_enableGestureScroll = YES;

5、在子控制器的scrollViewDidScroll:代理方法调用

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self.yb_suspendManage subScrollViewDidScroll:scrollView];
}

6、在主控制器实现代理方法,就是计算悬停位置,返回 YES or NO

#pragma mark - YBScrollSuspendManageDelegate
- (BOOL)enableSuspendForSubScroll:(UIScrollView *)subScrollView
{
    CGRect rect = [self.bookmarkView convertRect:self.bookmarkView.bounds toView:self.view];
    if (rect.origin.y <= 0) {
        //需要悬浮
        return YES;
    }
    return NO;
}

然后…然后效果就出来啦🙂

Author

Ethanbing, [email protected]

License

YBScrollSuspendManage is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "YBScrollSuspendManage",
    "version": "0.1.0",
    "summary": "u9875u9762u5d4cu5957u6edau52a8u5230lu67d0u4e2au70b9u60acu505cu6548u679c",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/ethanbing/YBScrollSuspendManage",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "[email protected]": "[email protected]"
    },
    "source": {
        "git": "https://github.com/ethanbing/YBScrollSuspendManage.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "YBScrollSuspendManage/Classes/**/*"
}

Pin It on Pinterest

Share This