美文网首页
UITableView 总结 2020

UITableView 总结 2020

作者: Look2021 | 来源:发表于2020-06-28 15:05 被阅读0次
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kAdaptedFloat(20))];
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.backgroundColor = [UIColor clearColor];
        _tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.showsHorizontalScrollIndicator = NO;
    }
    return _tableView;
}
#pragma mark ------- UITableViewDelegate -------

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return kAdaptedFloat(50);
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [UITableViewCell cellForTableView:tableView];
}
//根据cell, 刷新cell
NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    [self.tableView reloadRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationNone];

// 用storyboard创建UITableViewController
+ (instancetype)gh_sweepermanagement {
    return [[UIStoryboard storyboardWithName:NSStringFromClass(self) bundle:nil] instantiateViewControllerWithIdentifier:NSStringFromClass(self)];
}

//tableview既要有左滑删除又要有全选删除
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (self.collectTableView.editing) {
        return UITableViewCellEditingStyleDelete | UITableViewCellEditingStyleInsert;
    }else{
        return UITableViewCellEditingStyleDelete;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *GHHomePageDVcellID = @"GHHomePageDVcellID";
    GHHomePageDVcell *cell = [tableView dequeueReusableCellWithIdentifier:GHHomePageDVcellID];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"GHHomePageDVcell" owner:nil options:nil] firstObject];
    }
    
    return cell;
}
tableViewCell
//cell选中没有效果
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[tableView deselectRowAtIndexPath:indexPath animated:NO];
//改变全选cell,左边的选中颜色
cell.tintColor = [UIColor orangeColor];

//改变cell的背景颜色(选择cell的颜色)
UIView *backgroundViews = [[UIView alloc]initWithFrame:cell.frame];
backgroundViews.backgroundColor = [UIColor whiteColor];
[cell setSelectedBackgroundView:backgroundViews];

相关文章

  • UITableView 总结 2020

    tableViewCell

  • TableView基础

    总结一些UITableView常见的问题 和 常用的方法iOS UITableView的多选UITableView...

  • UITableView总结

    大致内容 基本介绍 UITableView有两种风格:UITableViewStylePlain和UITableV...

  • UITableView 总结

    UITableView是UIScrollView的子类,因此它可以自动响应滚动事件(一般为上下滚动)。 它内部包含...

  • UITableView 总结

    1.创建tableView self.tableview= [[UITableViewalloc]initWith...

  • UITableView的性能优化,提升列表滚动的流畅性

    原文:UITableView的性能优化,提升列表滚动的流畅性 本篇博客目的是:总结UITableView性能优化方...

  • UITableView 编辑模式详解

    UITableView 编辑模式详解 UITableView的相关编辑操作非常全,今天我们来做一个总结。跟编辑相关...

  • 为什么要基于UITableview构建UI

    实在吃过太多页面设计的亏,所以总结一下基于UITableview构建UI的一些好处。 UITableview是数据...

  • UITableView

    最近做的项目中用的UITableView比较多,在这里对UITableView的使用简单做一下总结。 @proto...

  • UITableView

    IOS中UITableView使用总结 一、初始化方法 - (instancetype)initWithFrame...

网友评论

      本文标题:UITableView 总结 2020

      本文链接:https://www.haomeiwen.com/subject/jahwfktx.html