IOS UITableView Group&Section
UItableView 根据数据结构不同 会有不同样式 关键在两个代理 tableviewdelegate&tabledatasourse
下面代码是我实施的Group 在模拟器中 ios6.1和ios7
并且滚动后相应的section会“置顶”,效果不错哦!
核心代码:
#import <UIKit/UIKit.h> @interface AnnouncementViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
{
UITableView *tableView_Inform;
} @end
////////////////////////////////////////////////////// - (void)viewDidLoad
{
[self.view addSubview: [NavView NavView_Title:@"通告"]];
[super viewDidLoad];
[self TableView];
}
-(void)TableView
{
if(StatusBar_System>)
{
moment_status_bar=;
}
tableView_Inform=[[UITableView alloc]initWithFrame:CGRectMake(, +moment_status_bar, ,Phone_Height-- )];
[self.view addSubview:tableView_Inform];
tableView_Inform.dataSource=self;
tableView_Inform.delegate=self;
}
/*
ios7以前的group 一般是圆角的,ios7以后没有圆角 苹果鼓励并支持更大的阅读面积 所以我把ios6的圆角也去掉了 也挺帅的 不是么
*/
//每一个section中间的宽度 可以根据需要设定 如果第一个section不需要宽度 就return 0;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
if (!section == ) { return 44.0;
} else {
return 44.0;
}
}
//一共有几组 返回有几个 section 块
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return ;
}
//每组有几行 返回 每个块 有几行cell
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return ;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSArray *array=[NSArray arrayWithObjects:@"One",@"Two", @"Three",@"Four",nil];
return [array objectAtIndex:section];
}
//cell注意数据结构的变化 indexPath.row 是循环变化的
//这里cell 我是写死的 可以自定义哦哦
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier: SimpleTableIdentifier] ;
}
NSLog(@"%d",indexPath.row);
return cell;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
附加 ios6和ios7的两个效果图


IOS UITableView Group&Section的更多相关文章
- iOS UITableView的Section Footer加入button
郝萌主倾心贡献,尊重作者的劳动成果.请勿转载. 假设文章对您有所帮助,欢迎给作者捐赠.支持郝萌主,捐赠数额任意.重在心意^_^ 我要捐赠: 点击捐赠 Cocos2d-X源代码下载:点我传送 在处理UI ...
- IOS UITableView NSIndexPath属性讲解
IOS UITableView NSIndexPath属性讲解 查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...
- 下拉刷新和UITableView的section headerView冲突的原因分析与解决方案
UITableView:下拉刷新和上拉加载更多 [转载请注明出处] 本文将说明具有多个section的UITableView在使用下拉刷新机制时会遇到的问题及其解决方案. 工程地址在帖子最下方,只需要 ...
- iOS UITableView划动删除的实现
标签:划动删除 iphone 滑动删除 ios UITableView 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://rainb ...
- 快速设置UITableView不同section对应于不同种类的cell
快速设置UITableView不同section对应于不同种类的cell 本文主要是为了写明如何在UITableView中,一个section对应于一种类型的cell,写起来不凌乱. 在不封装任何类的 ...
- iOS UITableView Tips(2)
#TableView Tips(2) (本来想一章就结束TableView Tips,但是发现自己还是太天真了~too young,too simple) ##架构上的优化 在Tips(1)中指出了一 ...
- ios 更改UITableview group形式 两个section之间的距离
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section { return 1.0 ...
- IOS UItableView得到group如何摆脱的剪裁线条样式问题
在他们的定义UItableView什么时候,选择当style至Group时间,后常透明切割线依然,去除.只有再次刷新了BackgroundView它可以覆盖原来的 //取消切割线 UIView *vi ...
- iOS UITableView中关于cell里的按钮被点击时如何确定是哪一个section
在section=10:row=1:的UITableView中,每一个cell都带有一个按钮,例如如下的图片一样每一个cell中都有一个“进入店铺的按钮”,但是如果我点击相应的cell要进入对应的店铺 ...
随机推荐
- Database事件研究
1.Database.ObjectAppended.ObjectModified.ObjectErased事件 此事件如果不是Transaction提交而触发的,那么可以在事件内部使用Transact ...
- POJ 3169 Layout (差分约束)
题意:给定一些母牛,要求一个排列,有的母牛距离不能超过w,有的距离不能小于w,问你第一个和第n个最远距离是多少. 析:以前只是听说过个算法,从来没用过,差分约束. 对于第 i 个母牛和第 i+1 个, ...
- Lucene/ElasticSearch 学习系列 (2) Information Retrival 初步之名词解释
计算机领域一半是理论,一半是在理论基础之上的应用.要想深入地掌握某个方面的应用,就需要先学习那方面的理论. “搜索”是应用,其背后的理论是 "Information Retrieval&qu ...
- Linux下生成动态链接库是否必须使用 -fPIC 的问题[转]
在 Linux 下制作动态链接库,“标准” 的做法是编译成位置无关代码(Position Independent Code,PIC),然后链接成一个动态链接库.经常遇到的一个问题是 -fPIC 是不是 ...
- jquery视频展示 图片轮播
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- Java中String对象的不可变性
首先看一个程序 package reverse; public class Reverse { public static void main(String[] args) { String c1=n ...
- EXTJS中的grid显示实际行号
添加一个新的功能 Ext.grid.PageRowNumberer = Ext.extend(Ext.grid.RowNumberer, { width : 40, renderer:function ...
- ExtJs内的datefield控件选择日期过后的事件监听select
[摘要]: 选择时间过后我们为什么需要监听事件?一般有这样一种情况,那就是用于比较两个时间大小或者需要判断在哪个时间点上需要做什么样的操作.基于这样的种种情况,我们很有必要琢磨一下datefield控 ...
- C++ Bit Fields
http://msdn.microsoft.com/en-us/library/ewwyfdbe%28v=vs.71%29.aspx Note An unnamed bit field of widt ...
- PE文件数字签名信息读取存储及格式具体解释图之上(历史代码,贴出学习)
// 注意下图PE文件格式具体解释图中的 // IMAGE_NT_HEADERS------->OptionalHeader------>DataDirectory[IMAGE_DIREC ...