tableView简单建立
2015-12-25 14:16
330 查看
1:代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}// Default is 1 if not implemented
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.userRoleArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * cellIdentifile = @"JJRoleTableViewCell";
JJRoleTableViewCell * roleCell =[tableView dequeueReusableCellWithIdentifier:cellIdentifile];
if (roleCell==nil) {
roleCell = [[JJRoleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifile];
}
[roleCell loadData:self.userRoleArray[indexPath.row]];
return roleCell;
}
----
cell:
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
}
return self;
}
2:xib
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}// Default is 1 if not implemented
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.userRoleArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * cellIdentifile = @"JJRoleTableViewCell";
JJRoleTableViewCell * roleCell =[tableView dequeueReusableCellWithIdentifier:cellIdentifile];
if (roleCell==nil) {
roleCell = [[[NSBundle mainBundle]loadNibNamed:cellIdentifile owner:self options:nil]firstObject];
}
[roleCell loadData:self.userRoleArray[indexPath.row]];
return roleCell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}// Default is 1 if not implemented
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.userRoleArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * cellIdentifile = @"JJRoleTableViewCell";
JJRoleTableViewCell * roleCell =[tableView dequeueReusableCellWithIdentifier:cellIdentifile];
if (roleCell==nil) {
roleCell = [[JJRoleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifile];
}
[roleCell loadData:self.userRoleArray[indexPath.row]];
return roleCell;
}
----
cell:
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
}
return self;
}
2:xib
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 1;
}// Default is 1 if not implemented
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return self.userRoleArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString * cellIdentifile = @"JJRoleTableViewCell";
JJRoleTableViewCell * roleCell =[tableView dequeueReusableCellWithIdentifier:cellIdentifile];
if (roleCell==nil) {
roleCell = [[[NSBundle mainBundle]loadNibNamed:cellIdentifile owner:self options:nil]firstObject];
}
[roleCell loadData:self.userRoleArray[indexPath.row]];
return roleCell;
}
相关文章推荐
- Mycat配置文件之server.xml
- Proguard使用最新,最全教程,亲自试验
- 如何关闭Linux里边的selinux ?
- 一个Node.js初学者的“班门弄斧
- mysql-创建函数,存储过程以及视图
- select onchagnge 弹出自己的文本值
- 数据结构课程设计-学生信息管理系统
- Root Pane Container(四)
- JSON数据格式
- ios7中将状态栏变白的几种方式
- 开发小结
- 让textarea和附近的文字居中对齐
- html5开发之viewport使用
- Web_PHP_ThinkPHP_CURD方法盘点:where方法;
- Tasks and Back Stack(任务和返回栈)
- Android酷炫实用的开源框架(UI框架)
- 分享Linux 系统生成随机密码的10种方法
- 定时器
- Mybatis3源码分析(20)-Mapper实现-配置加载
- 在子线程里面使用Toast