iPhone开发——在tableViewTable中创建tableCell,不同分区含有不同数量的Cell
2013-04-18 17:54
337 查看
1、确定tableView中的分区数
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
2、确定每个section中的cell数量
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
case 0:
return 1;
break;
case 1 :
return 1;
break;
default:
break;
}
return 1;
}
3、确定Cell中的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Configure the cell...
switch (indexPath.section) {//哪一个分区
case 0:
switch (indexPath.row) {//分区中的哪一行
case 0:
cell.textLabel.text=@"1";
break;
default:
break;
}
break;
case 1:
switch (indexPath.row) {//分区中的哪一行
case 0:
cell.textLabel.text=@"66";
break;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return cell;
}
4、点击cell时
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
原文地址:http://blog.sina.com.cn/s/blog_9ae642d70100xlyt.html
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 2;
}
2、确定每个section中的cell数量
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
switch (section) {
case 0:
return 1;
break;
case 1 :
return 1;
break;
default:
break;
}
return 1;
}
3、确定Cell中的内容
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Configure the cell...
switch (indexPath.section) {//哪一个分区
case 0:
switch (indexPath.row) {//分区中的哪一行
case 0:
cell.textLabel.text=@"1";
break;
default:
break;
}
break;
case 1:
switch (indexPath.row) {//分区中的哪一行
case 0:
cell.textLabel.text=@"66";
break;
default:
break;
}
break;
default:
break;
}
break;
default:
break;
}
return cell;
}
4、点击cell时
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
原文地址:http://blog.sina.com.cn/s/blog_9ae642d70100xlyt.html
相关文章推荐
- 在tableViewTable中创建tableCell,不同分区含有不同数量的Cell
- IPhone开发中tableview cell的气泡样式的实现
- iphone开发 tableview中cell的用法
- iphone开发 tableview中cell的用法
- [iPhone 开发]tableview中cell的设置 (转)
- iPhone开发之TableView
- iOS开发技巧-tableView去掉多余的空行分割线,自定义Cell分割线
- ios开发技巧之tableView去掉多余的空行分割线 自定义cell分割线
- iOS开发- TableView不显示没内容的Cell
- 学习IOS开发UI篇--UITableView中Cell的创建方式总结
- IOS开发 tableview中cell的用法
- Swift - 设置tableView每个分区cell圆角
- tableView 使用注意事项:一个tableView展示不同的cell时复用,以及数据更新
- 【iOS7开发笔记】tableview之通过代码自定义cell(cell的高度不一致)
- ios中Tableview的两个获得重用cell方法的区别?(兼容iPhone5.0之前的版本)
- iphone开发UITable内嵌不同风格Table
- iPhone开发【七】常用控件之表TableView
- IOS开发之TableView、多个TableViewCell、自定义Cell、Cell上画画(故事板+代码方式)
- iOS开发使用sdWebImage实现对tableView的cell加载图片淡入动画
- [How to]使用自定义cell进行tableview的创建,适用于cell样式不发生变化的情况。