#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. stl_algo.h

    stl_algo.h // Filename: <stl_algo.h> // Comment By: 凝霜 // E-mail: mdl2009@vip.qq.com // Blog: ...

  2. https页面 和 http请求的问题

    (1)强制升级http 静态资源地址为https地址 https页面中不能使用http请求,http页面中可以使用https请求. 关于在https 页面有一些http的请求,可以在<head& ...

  3. 每天一个linux命令(15):head命令

    版权声明更新:2017-05-19博主:LuckyAlan联系:liuwenvip163@163.com声明:吃水不忘挖井人,转载请注明出处! 1 文章介绍 本文介绍了Linux下面的mv命令. 2. ...

  4. 1117. Eddington Number(25)

    British astronomer Eddington liked to ride a bike. It is said that in order to show off his skill, h ...

  5. 团队队列(列和map结合的经典运用)

    Queues and Priority Queues are data structures which are known to most computer scientists. The Team ...

  6. 【LeetCode】001. TwoSum

    题目: Given an array of integers, return indices of the two numbers such that they add up to a specifi ...

  7. vmem驱动设备

    vmem是内存多字符设备.包含vfs的open.read.write.ioctl.poll.fasync和release函数,device文件的读写. virtual_mem.c #include & ...

  8. Mysql事件的创建和使用

    1.查看事件是否开启SHOW VARIABLES LIKE 'event_scheduler'; 2.开启事件SET GLOBAL event_scheduler = ON; 3.创建事件DELIMI ...

  9. 【Linux网络编程】基于TCP流 I/O多路转接(poll) 的高性能http服务器

    服务器比较简陋,为了学习poll的使用,只向客户端回写一条html语句.启动服务器后,浏览器发起请求,服务端向浏览器写回html,响应字符串,然后可以看到,浏览器解析并显示 Hello Poll!. ...

  10. 几种排序方式的java实现(02:希尔排序,归并排序,堆排序)

    代码(部分为别人代码): 1.希尔排序(ShellSort) /* * 希尔排序:先取一个小于n的整数d1作为第一个增量, * 把文件的全部记录分成(n除以d1)个组.所有距离为d1的倍数的记录放在同 ...