文章来源:淘论文网   发布者: 毕业设计   浏览量: 44

定做请加QQ:1052602713 或加微信:


还可以点击去查询以下关键词:
[GJStaticTableView]    [静态]    [TableView]    [GJStaticTableView静态TableView]   

项目介绍:

GJStaticTableView

GJStaticTableView是一个静态的TableView控件,如果你用过Storyboard的话,一定对其中的静态TableView有印象,然而在实际开发中,我们也经常需要这种控件,例如在非信息流的列表型的展示页面,我们并不需要进行Cell复用,然而你也可能因为某些原因不希望使用Storyboard,这时你可以使用GJStaticTableView了。

Installation

可以直接将项目中GJStaticTableView文件夹Copy到工程目录中

也可以使用CocoaPods进行集成

pod 'GJStaticTableView'UsageCreating a GJStaticTableView

你需要继承GJStaticTableView,在子类中只需要将自定义的Cell使用@property进行声明即可。

#import 'GJStaticTableView.h' #import 'GJTableViewCell0.h' #import 'GJTableViewCell1.h' #import 'GJTableViewCell2.h' #import 'GJTableViewCell3.h' #import 'GJTableViewCell4.h' @interface CustomTableView : GJStaticTableView @property (nonatomic, strong) GJTableViewCell0 *cell0; @property (nonatomic, strong) GJTableViewCell1 *cell1; @property (nonatomic, strong) GJTableViewCell2 *cell2; @property (nonatomic, strong) GJTableViewCell3 *cell3; @property (nonatomic, strong) GJTableViewCell4 *cell4; @end

然后将这个CustomTableView生成实例add到界面上去吧

self.tableView = [[CustomTableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; [self.view addSubview:self.tableView];

run一下看看效果

Delegate & DataSourceCell Height

默认情况下,GJStaticTableView会采用FDTemplateLayoutCell计算Cell的高度并自动设置,开题报告,你只需按照Autolayout的约束规范将Cell内的元素与Cell进行约束,将其撑起高度即可。
某些情况下,如果你希望自己给Cell设定一个静态高度,开题报告,那么你可以让这个Cell实现GJStaticCellPotocol中的gj_rowHeight方法,返回一个高度值即可。

#import 'GJTableViewCell1.h' @implementation GJTableViewCell1 - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { //Code ... } return self; } - (CGFloat)gj_rowHeight { return 40; } @end

如果这还不能满足你的要求,那么你可以设置tableView的delegate来自己实现tableView:heightForRowAtIndexPath:方法。

@interface ViewController () <UITableViewDelegate> @property (nonatomic, strong) CustomTableView *tableView; @end @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; self.tableView = [[CustomTableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain]; self.tableView.delegate = self; [self.view addSubview:self.tableView]; } - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { //custom height }Other delegate & dataSource

如果你想使用其他UITableView的特性,你只需向上面一样设置好delegate和dataSource,
注意:在GJStaticTableView内,我们使用了4个方法:

numberOfSectionsInTableView:

tableView:heightForRowAtIndexPath:

tableView:numberOfRowsInSection:

tableView:cellForRowAtIndexPath:

你需要注意他们对你自定义代理方法的影响

github地址:https://github.com/GJGroup/GJStaticTableView


这里还有:


还可以点击去查询:
[GJStaticTableView]    [静态]    [TableView]    [GJStaticTableView静态TableView]   

请扫码加微信 微信号:sj52abcd


下载地址: http://www.taolw.com/down/7533.docx
  • 上一篇:一款功能极其毕业设计强大的图表库.
  • 下一篇:一个近乎完整的可识别中国身份证信息的Demo 可自动快速...