Latest 0.1.6
Homepage https://github.com/ablettchen/ATList
License MIT
Platforms ios 8.0, requires ARC
Dependencies MJRefresh, ATBlank
Authors

CI Status
Version
License
Platform

Example

  1. 通用配置(可选,如不配置,则使用默认)
#import "UIScrollView+ATList.h"
@implementation ATAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [ATCenter setupConfig:^(ATConfig * _Nonnull config) {
        config.loadType = ATLoadTypeAll;
        config.loadStrategy = ATLoadStrategyAuto;

        ATBlank *failureBlank = blankMake(blankImage(ATBlankTypeFailure), @"数据请求失败☹️", @"200014");
        ATBlank *noDataBlank = blankMake(blankImage(ATBlankTypeNoData), @"暂时没有数据🙂", @"哈哈哈~");
        noDataBlank.tapEnable = NO;
        ATBlank *noNetworkBlank = blankMake(blankImage(ATBlankTypeNoNetwork), @"貌似没有网络🙄", @"请检查设置");

        config.blankDic = @{@(ATBlankTypeFailure)   : failureBlank,
                            @(ATBlankTypeNoData)    : noDataBlank,
                            @(ATBlankTypeNoNetwork) : noNetworkBlank,
                            };

        config.length = 18;
    }];

    return YES;
}
@end
  1. 具体页面中使用
#import "UIScrollView+ATList.h"
//加载数据
__weak __typeof(&*self)weakSelf = self;
[self.tableView loadConfig:^(ATConfig * _Nonnull config) {

    // 1. 针对具体页面进行配置(可选);
    //config.loadType = ATLoadTypeNew;
    //config.loadStrategy = ATLoadStrategyAuto;
    //config.blankDic = @{@(ATBlankTypeFailure) : blankMake(blankImage(ATBlankTypeFailure), @"绘本数据加载失败", @"40015")};
    //config.length = 15;

} start:^(ATList * _Nonnull list) {

    // 2. 发起请求;
    NSDictionary *parameters = @{@"offset"  : @(list.range.location),
                                 @"number"  : @(list.range.length)};
    __strong __typeof(&*self)strongSelf = weakSelf;
    [weakSelf requestData:parameters finished:^(NSError *error, NSArray *datas) {

        // 3. 添加数据(当前加载状态为下拉刷新时移除旧数据);
        if (list.loadStatus == ATLoadStatusNew) [strongSelf.datas removeAllObjects];
        if (datas && datas.count > 0) [strongSelf.datas addObjectsFromArray:datas];

        // 4. 刷新页面。
        [list finish:error];
    }];
}];

/** 若 config.loadStrategy = ATLoadStrategyManual,则需要手动调用 [self.tableView.at_list loadNew];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [self.tableView.at_list loadNew];
});
 */

Requirements

Installation

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

pod 'ATList'

Author

ablett, [email protected]

License

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

Latest podspec

{
    "name": "ATList",
    "version": "0.1.6",
    "summary": "u5febu901fu914du7f6eu4e0bu62c9u5237u65b0u3001u4e0au62c9u52a0u8f7du3001u7a7au767du9875uff0cu9002u7528u4e8e UITableViewu3001UICollectionViewu3001UIScrollView",
    "homepage": "https://github.com/ablettchen/ATList",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "ablettchen": "[email protected]"
    },
    "social_media_url": "https://weibo.com/ablettchen",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/ablettchen/ATList.git",
        "tag": "0.1.6"
    },
    "source_files": "ATList/**/*.{h,m}",
    "requires_arc": true,
    "dependencies": {
        "MJRefresh": [],
        "ATBlank": []
    }
}

Pin It on Pinterest

Share This