#import <UIKit/UIKit.h>

 @interface AppDelegate : UIResponder <UIApplicationDelegate>

 @property (strong, nonatomic) UIWindow *window;

 @end
 #import "AppDelegate.h"
#import "RootViewController.h"
@interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor]; RootViewController *root = [[RootViewController alloc] init];
UINavigationController *navi = [[UINavigationController alloc] initWithRootViewController:root];
self.window.rootViewController = navi; [self.window makeKeyAndVisible];
return YES;
} @end
 #import <UIKit/UIKit.h>

 @interface RootViewController : UIViewController

 @end
 #import "RootViewController.h"

 @interface RootViewController ()<UITableViewDataSource,UITableViewDelegate>
{
UITableView *_tableView;
NSMutableDictionary *dataDic;
}
@end @implementation RootViewController - (void)loadView
{
[super loadView];
_tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] bounds] style:UITableViewStyleGrouped];
_tableView.delegate = self;
_tableView.dataSource = self;
[self.view addSubview:_tableView];
} - (void)viewDidLoad {
[super viewDidLoad];
NSArray *A = [NSArray arrayWithObjects:@"app",@"apple",@"alex",@"alert",@"alright",@"at",@"addic",@"awake",@"action",@"active", nil];
NSArray *B = [NSArray arrayWithObjects:@"belance",@"beyond",@"bell",@"bill",@"bet",@"bety",@"bright",@"beaty",@"beat",@"bite",@"bit",@"bake",@"blake",@"basket",@"basketball",@"ball",@"black",@"blue", nil];
NSArray *C = [NSArray arrayWithObjects:@"cake",@"cat",@"cap",@"cook",@"cooki",@"cate",@"cell",@"certain",@"city",@"clabe",@"clab",@"copy",@"cry", nil];
NSArray *D = [NSArray arrayWithObjects:@"dirty",@"del",@"directly",@"dry",@"dull",@"delly",@"dute", nil];
NSArray *E = [NSArray arrayWithObjects:@"elphance",@"every",@"else",@"emperty", nil];
NSArray *F = [NSArray arrayWithObjects:@"fly",@"flash",@"flag",@"fate",@"felt",@"fill",@"fell",@"fall",@"font",@"fake",@"flour",@"ferver",@"fetech", nil];
NSArray *G = [NSArray arrayWithObjects:@"girl",@"gipe",@"grap",@"gray",@"gay",@"gita",@"git",@"get",@"great",@"glass",@"glasses",@"good",@"google", nil];
dataDic = [NSMutableDictionary dictionaryWithObjectsAndKeys:A,@"A",B,@"B",C,@"C",D,@"D",E,@"E",F,@"F",G,@"G", nil];
} #pragma mark -UITableView Delegate- - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return [[dataDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
} - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [dataDic allKeys].count;
} - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSArray *keys = [[dataDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
NSString *key = keys[section];
NSArray *array = dataDic[key];
return [array count];
} - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSArray *keys = [[dataDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
NSString *key = keys[section];
return key;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identify = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identify];
}
NSArray *keys = [[dataDic allKeys] sortedArrayUsingSelector:@selector(compare:)];
NSString *key = keys[indexPath.section];
NSArray *array = dataDic[key];
NSString *content = array[indexPath.row];
cell.textLabel.text = content;
return cell;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

IOS UITableView分组与索引分区实例的更多相关文章

  1. IOS UITableView分组列表

    UITableView有两种风格:UITableViewStylePlain和UITableViewStyleGrouped.这两者操作起来其实并没有本质区别,只是后者按分组样式显示前者按照普通样式显 ...

  2. IOS UITableView的代理方法详解

    一.UITableViewDataSourc(数据源代理) 1.必须实现的回调方法 返回每个分区的行数 - (NSInteger)tableView:(UITableView *)tableView ...

  3. iOS UITableView Tips(2)

    #TableView Tips(2) (本来想一章就结束TableView Tips,但是发现自己还是太天真了~too young,too simple) ##架构上的优化 在Tips(1)中指出了一 ...

  4. SQL Server 解读【已分区索引的特殊指导原则】(3) - 非聚集索引分区

    一.前言 在MSDN上看到一篇关于SQL Server 表分区的文档:已分区索引的特殊指导原则,如果你对表分区没有实战经验的话是比较难理解文档里面描述的意思.这里我就里面的一些概念进行讲解,方便大家的 ...

  5. IOS UITableView NSIndexPath属性讲解

    IOS UITableView NSIndexPath属性讲解   查看UITableView的帮助文档我们会注意到UITableView有两个Delegate分别为:dataSource和deleg ...

  6. 第十三章——表和索引分区(1)——使用Range Left进行表分区

    原文:第十三章--表和索引分区(1)--使用Range Left进行表分区 前言: 如果数据表的数据持续增长,并且表中的数据量已经达到数十亿甚至更多,数据的查询和操作将非常困难,面对非常庞大的表,几时 ...

  7. iOS UITableView划动删除的实现

    标签:划动删除 iphone 滑动删除 ios UITableView 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://rainb ...

  8. Oracle之索引(Index)实例解说 - 基础

    Oracle之索引(Index)实例解说 - 基础 索引(Index)是关系数据库中用于存放表中每一条记录位置的一种对象.主要目的是加快数据的读取速度和数据的完整性检查.索引的建立是一项技术性要求很高 ...

  9. ORA-14061: 不能更改索引分区列的数据类型或长度

    修改分区表主键时报错: 在行: 2 上开始执行命令时出错 -alter table KC23 modify AAZ210 VARCHAR2(50)错误报告 -SQL 错误: ORA-14061: 不能 ...

随机推荐

  1. IaaS中的统一存储:从设计到实现

    转自:https://www.ustack.com/blog/tycc/ “原生的OpenStack并不支持统一存储,云主机服务Nova.镜像服务Glance.云硬盘服务Cinder的后端存储各不相同 ...

  2. hdu1085 Holding Bin-Laden Captive!(母函数)

    简单的母函数应用. #include<iostream> #include<cstdio> #include<cstdlib> #include<cstrin ...

  3. 【数论】卡塔兰数 Catalan

    一.简介 设$h(0)=1$,$h(1)=1$,Catalan数满足递推式 $h(n) = h(0) \ast h(n-1) + h(1)\ast h(n-2) + \cdots + h(n-1)\a ...

  4. JavaWeb框架_Struts2_(一)----->Struts2 框架入门

    1.  框架入门 2.1  Struts2简介 (1). Struts2是一种基于MVC模式的的轻量级Web开发框架. MVC模式:MVC全名是Model View Controller,是模型(mo ...

  5. CentOS下安装Python3.4

    系统环境:CentOS 7.2 CentOS7安装Python3.4 ,让Python2和3共存 编译需要的一些包: yum -y groupinstall "Development too ...

  6. [转载]create_proc_read_entry中函数的说明

    原型: struct proc_dir_entry *create_proc_read_entry (const char *name, mode_t mode, struct proc_dir_en ...

  7. 转载:trap 的用法 /etc/init.d/rcS trap :1 2 3 24

    在有些情况下,我们不希望自己的shell脚本在运行时刻被中断,比如说我们写得shell脚 本设为某一用户的默认shell,使这一用户进入系统后只能作某一项工作,如数据库备份, 我 们可不希望用户使用c ...

  8. Windows:cmd的使用

    1.如果在cmd.exe中无法运行软件(如python),因为在系统的环境变量中,path中没有该软件的安装路径: 2.通过pip安装软件:pip install 文件路径\文件全名,将软件安装在指定 ...

  9. Python:格式化操作符(%)

    原文作者:田小计划 原文出处:http://www.cnblogs.com/wilber2013/ (若转载,请标明原文出处) 在编写程序的过程中,经常需要进行格式化输出,每次用每次查.干脆就在这里整 ...

  10. &(((struct A*)NULL)->m_float)---offsetof

    问题描述: struct A { int m_int; float m_float; }; int main(void) { printf("%p",&(((struct ...