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要进入对应的店铺 ...
随机推荐
- ARM内核全解析
前不久ARM正式宣布推出新款ARMv8架构的Cortex-A50处理器系列产品,以此来扩大ARM在高性能与低功耗 领域的领先地位,进一步抢占移动终端市场份额.Cortex-A50是继Cortex-A1 ...
- [转]Android在初始化时弹出popwindow的方法 .
转自:http://blog.csdn.net/sxsboat/article/details/7340759 留个人备用0.0 Android中在onCreate()时弹出popwindow,很多人 ...
- shutdown 和closesocket
来,咱们彻底的来讨论一下这个shutdown 和closesocket 从 函数调用上来分析(msdn):一旦完成了套接字的连接,应当将套接字关闭,并且释放其套接字句柄所占用的所有资源.真正释放一 ...
- mahout算法源码分析之Itembased Collaborative Filtering(四)共生矩阵乘法
Mahout版本:0.7,hadoop版本:1.0.4,jdk:1.7.0_25 64bit. 经过了SimilarityJob的计算共生矩阵后,就可以开始下面一个过程了,这个过程主要是共生矩阵的乘法 ...
- 《Java程序员修炼之道》
原子类:java.util.concurrent.atomic 线程锁:java.util.concurrent.locks 对付死锁:boolean acquired = lock.tryLock( ...
- 使用 EasyMock 更轻松地进行测试
from:http://www.ibm.com/developerworks/cn/java/j-easymock.html 测试驱动开发是软件开发的重要部分.如果代码不进行测试,就是不可靠的.所有代 ...
- gitignore无效最简单解决办法
git rm --cached 文件或者文件夹 git commit 提交 git push 提交
- JDBC-ODBC桥乱码问题解决方案
按照网上提供的ODBC连接数据库的相关资料编写代码,成功编译后运行发现,非中文字段显示正确,而中文字段却是每个汉字以?显示.关于这方面的错误baidu或google下可以找到很多解答方案,我也尝试过其 ...
- CodeForces 164A Variable, or There and Back Again 搜索
Variable, or There and Back Again 题目连接: http://codeforces.com/problemset/problem/164/A Description L ...
- cdoj 65 CD Making 水题
CD Making Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.uestc.edu.cn/#/problem/show/65 De ...