基于UITableView写的简单通讯录
来源:互联网 发布:愿你知我心 mp3 下载 编辑:程序博客网 时间:2024/04/28 03:57
主要代码
点击打开链接可以在这下载写的工程代码
#import "RootViewController.h"#import "Student.h"@interface RootViewController ()<UITableViewDataSource,UITableViewDelegate>@property (nonatomic, retain)NSDictionary *dic;@property (nonatomic, retain)NSArray *titles;@end@implementation RootViewController- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization [selfreadDataFromPlist]; self.titles = [[self.dicallKeys] sortedArrayUsingSelector:@selector(compare:)]; } return self;}- (void)readDataFromPlist{ NSString *filePath = [[NSBundlemainBundle] pathForResource:@"AddressBook1"ofType:@"plist"]; self.dic = [NSDictionarydictionaryWithContentsOfFile:filePath];}- (void)loadView{ UITableView *tableView = [[UITableViewalloc] initWithFrame:[UIScreenmainScreen].bounds style:UITableViewStylePlain]; tableView.separatorColor = [UIColororangeColor]; //指定tableView的数据源(为tableView显示数据支持)需要服从UItableViewDateSouce协议 tableView.dataSource = self; //设置tableView的代理(用来处理cell的滴啊你事件) tableView.delegate = self; //设置行高 tableView.rowHeight = 80; self.view = tableView; [tableView release];}- (void)viewDidLoad{ [superviewDidLoad]; // Do any additional setup after loading the view. self.view.backgroundColor = [UIColorgrayColor]; //设置标题 self.navigationItem.title =@"河南9班通讯录";}#pragma mark - UITableViewDataSource- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [self.dic[self.titles[section]]count];}//用来创建cell,每一行都i要对应一个cell- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ Student *cell = [[Studentalloc] initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:nil]; cell.photoView.image= [UIImageimageNamed:self.dic[self.titles[indexPath.section]][indexPath.row][@"imageName"]]; cell.nameLabel.text =self.dic[self.titles[indexPath.section]][indexPath.row][@"name"]; cell.ageLabel.text =self.dic[self.titles[indexPath.section]][indexPath.row][@"age"]; cell.genderLabel.text =self.dic[self.titles[indexPath.section]][indexPath.row][@"gender"]; cell.numberLabel.text =self.dic[self.titles[indexPath.section]][indexPath.row][@"phoneNumber"]; return [cell autorelease];}- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ return [self.diccount];}//设置每个分区的显示的文字(页眉)- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{ return self.titles[section];}//设置tableView右边的索引值(用来快速查找- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView{ return self.titles;}- (void)didReceiveMemoryWarning{ [superdidReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}/*#pragma mark - Navigation// In a storyboard-based application, you will often want to do a little preparation before navigation- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller.}*/- (void)dealloc{ self.dic = nil; self.titles = nil; [super dealloc];}@end
0 0
- 基于UITableView写的简单通讯录
- 基于二叉排序树写的通讯录
- UITableView带section的使用(可写通讯录)
- iOS开发-------简单通讯录(UITableView和CoreData的应用)
- 【汇编语言】写一个简单的通讯录
- php写一个简单的通讯录
- Swift 写个简单的UITableView
- UIday1002:UITableView 2 用UITableView实现通讯录cell简单的数据移动、删除、添加功能
- UITableView 类似通讯录的索引
- UITableView 类似通讯录的功能
- 自己写的一个简单JAVA网络通讯录
- 用C语言写一个简单的通讯录
- python 写的通讯录
- python写的通讯录
- 基于sqlite3实现的简单通讯录程序(控制台)
- 基于sqlite3实现的简单通讯录程序(控制台)
- 基于sqlite3的利用数据库实现简单通讯录
- 基于web制作最简单的通讯录具备curd操作
- 劝学
- 自旋锁和互斥锁区别
- 分享8个超棒的免费高质量图标搜索引擎
- 《Linux驱动基础篇》- Linux内存管理深入篇
- C++不会没落但会走精英化路线
- 基于UITableView写的简单通讯录
- C# 中的委托和事件(转)
- boost的配置与使用(vs2010)
- qt动画入门
- Java文件操作类封装
- WAS集群系列(6):集群搭建:步骤4:安装WAS升级软件
- iPhone和iPad的图标
- Java中线程的几种状态
- JAVA多线程和并发基础面试问答