SListView 1.0.1

SListView 1.0.1

测试已测试
语言语言 Obj-CObjective C
许可 MIT
发布最新发布2017年10月

wuxu维护。



SListView 1.0.1

  • x5
  • 支持水平滑动和轮播图的自定义tableView

功能

  • 自定义水平滑动tableView
  • 新增SLoopView支持无限轮播
  • 实现了复用机制
  • 有待完善垂直滑动和卡片样式

添加到Podfile

pod 'SListView','~>1.0.0'

如何使用SListView

- (void)viewDidLoad {
    [super viewDidLoad];
    self.dataSource = @[randomColor,randomColor,randomColor,randomColor,randomColor];
    [self.view addSubview:self.listView];
}
- (IBAction)reload:(id)sender {
    self.dataSource = @[randomColor,randomColor,randomColor,randomColor,randomColor,randomColor,randomColor,randomColor];
    [self.listView reloadData];
}

#pragma mark - SListViewDataSource
- (NSInteger)numberOfColumnsInListView:(SListView *)listView {
    return self.dataSource.count;
}
- (CGFloat)listView:(SListView *)listView widthForColumnAtIndex:(NSInteger)index  { 
    return index % 2? 70:90; 
}
- (SListViewCell *)listView:(SListView *)listView viewForColumnAtIndex:(NSInteger)index {
    static NSString *identifier = @"ListViewCellIdentifier";
    SListViewCell *cell = [listView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[SListViewCell alloc] initWithIdentifier:identifier];
    }
    [self configureCell:cell atIndex:index];
    return cell;
}
- (void)configureCell:(SListViewCell *)cell atIndex:(NSInteger )index {
    cell.backgroundColor = _dataSource[index];
}
#pragma mark - SListViewDelegate
- (void)listView:(SListView *)listView didSelectColumnAtIndex:(NSInteger)index {
    NSLog(@"listView didSelectColumnAtIndex >> %ld",index);
}
- (void)listView:(SListView *)listView didScrollToColumn:(SRange)range {
    NSLog(@"didScrollToColumn start:%ld  end:%ld",range.start,range.end);
}
#pragma mark - lazy init
- (SListView *)listView {
    if (!_listView) {
        _listView = [[SListView alloc] initWithFrame:CGRectMake(0, 150, CGRectGetWidth(self.view.frame), 200)];
        _listView.dataSource = self;
        _listView.delegate = self;
    }
    return _listView;
}

更新

  • V1.0.0
    1._visibleRect = CGRectZero,解决SLoopView出现瞬间空白页bug
    2.添加listViewCellSpace属性,替换kSpace。目的:将kSpace提供为API使用
    3.让delegate可调用scrollViewDidScroll:方法
    4.删掉if (_columns <= 0) return; 让_columns可为0
    5.完善SWeakTimerObject
  • V0.3.0
    1.新增SLoopView:支持无限轮播
    2.优化SListView
  • V0.2.0
    1.变宽
    2.新增和修改方法
    3.优化逻辑
  • V0.1.1
    1.修复reload bug,优化复用机制
  • V0.1.0
    1.首次上传