#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. CSS媒体查询 width VS device-width

    In CSS media the difference between width and device-width can be a bit muddled, so lets expound on ...

  2. [原创]Java动态填充word文档并上传到服务器

    一. 需求背景 在一些特殊应用场合,客户希望在服务器上生成文档的同时并填充数据,客户端的页面不显示打开文档,但是服务器上生成文档对服务器压力很大,目前服务器上生成文档第一种就是方式是jacob, 但是 ...

  3. Redis源码解析(1)——源码目录介绍

    概念 redis是一个key-value存储系统.和Memcached类似,它支持存储的value类型相对更多,包括string(字符串).list(链表).set(集合)和zset(有序集合).这些 ...

  4. 使用Innobackupex快速搭建(修复)MySQL主从架构

    MySQL的主从搭建大家有很多种方式,传统的mysqldump方式是很多人的选择之一.但对于较大的数据库则该方式并非理想的选择.使用Xtrabackup可以快速轻松的构建或修复mysql主从架构.本文 ...

  5. java学习笔记 --- 网络编程(套接字)

    1.Socket通信原理 Socket套接字概述: 网络上具有唯一标识的IP地址和端口号组合在一起才能构成唯一能识别的标识符套接字. 通信的两端都有Socket. 网络通信其实就是Socket间的通信 ...

  6. 剑指offer--6.数值的整数次方

    时间限制:1秒 空间限制:32768K 热度指数:362909 题目描述 给定一个double类型的浮点数base和int类型的整数exponent.求base的exponent次方. class S ...

  7. linux下的制作静态库并使用它

    静态库所要用的源文件 文件 fred.c   #include <stdio.h>   void fred(int argc) {     printf("void fred(i ...

  8. ACM学习历程—SNNUOJ1215 矩阵2(二分 && dfs)

    http://219.244.176.199/JudgeOnline/problem.php?id=1215 这是这次微软和百度实习面试的一道题,题目大意就是:有一个n*m的矩阵,已知它每一行都是不严 ...

  9. 机器学习:多项式回归(scikit-learn中的多项式回归和 Pipeline)

    一.scikit-learn 中的多项式回归 1)实例过程 模拟数据 import numpy as np import matplotlib.pyplot as plt x = np.random. ...

  10. linux 学习 端口占用 && 内存使用

    安装: apt-get update apt-get install net-tools Linux上:netstat -anop | grep ':50001' windows上:netstat - ...