版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、#import <UIKit/UIKit.h>interface ContactViewController : UITableViewControllerend#import "ContactViewController.h"#import "Person.h" /人的模型#import "HerosCel
2、l.h" /男#import "ScrollCell.h" /女#import "ViewController.h" &
3、#160; /跳转页面interface ContactViewController ()property (nonatomic,retain)NSMutableDictionary *dataSource;property (nonatomic,retain)NSMutableArray *orderAry;property (nonatomic,copy)NSString *str;
4、160; /传哪个值endimplementation ContactViewController- (NSMutableDictionary *)dataSource if (!_dataSource) self.dataSource = NSMutableDictionary dictionary; return _dataSource retain autor
5、elease;- (NSString *)str if (!_str) self.str = "name" return _str retain autorelease;- (NSMutableArray *)orderAry if (!_orderAry) s
6、elf.orderAry = NSMutableArray array; return _orderAry retain autorelease;- (void)viewDidLoad super viewDidLoad; / Uncomment the following line to preserve selection between presentations. /
7、self.clearsSelectionOnViewWillAppear = NO; / Uncomment the following line to display an Edit button in the navigation bar for this view controller. / self.navigationItem.rightBarButtonItem = self.editButtonItem;
8、; self readDataPlist; - (IBAction)handleSegment:(UISegmentedControl *)sender self.str = sender titleForSegmentAtIndex:sender.selectedSegmentIndex;- (void)readDataPlist NSString *path = NSBundle mainBundle pathForResource:"yingxiong" ofT
9、ype:"plist" NSDictionary *dict = NSDictionary dictionaryWithContentsOfFile:path; for (NSString *str in dict) NSMutableArray *mArray = NSMutableArray array;
10、160; for (NSDictionary *aHeros in dictstr) Person *person = Person alloc initWithName:aHeros; mArray addObject:person; &
11、#160; self.dataSource setObject:mArray forKey:str; NSArray *ary = dict.allKeys sortedArrayUsingSelector:selector(compare:); for (NSString *str in ary)
12、60; self.orderAry addObject:str; - (void)didReceiveMemoryWarning super didReceiveMemoryWarning; / Dispose of any resources that can be recreated.#pragma mark - Table view data source- (NSInteger)nu
13、mberOfSectionsInTableView:(UITableView *)tableView return self.orderAry.count;- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section return self.dataSourceself.orderArysection count;- (NSArray<NSString *> *)sectionIndexTit
14、lesForTableView:(UITableView *)tableView return self.orderAry;- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section return self.orderArysection;- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSI
15、ndexPath *)indexPath Person *person = self.dataSourceself.orderAryindexPath.section objectAtIndex:indexPath.row; if (person.gender isEqualToString:"女") ScrollCell *cell = tab
16、leView dequeueReusableCellWithIdentifier:"scrollCell" forIndexPath:indexPath; cell.scrollimageView.image = UIImage imageNamed:person.image; .text = ; &
17、#160; cell.type.text = person.type; return cell; else HerosCell *cell = tableView dequeueReusableCellWithIdentifier:"boyCell" forIndexPath:indexPath; cell set
18、ValueByPerson:person; return cell; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath self performSegueWithIdentifier:"xxx" sender:nil; /*/ Ov
19、erride to support conditional editing of the table view.- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath / Return NO if you do not want the specified item to be editable. return YES;*/*/ Override to support editing the tab
20、le view.- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath if (editingStyle = UITableViewCellEditingStyleDelete) / Delete the row from the dat
21、a source tableView deleteRowsAtIndexPaths:indexPath withRowAnimation:UITableViewRowAnimationFade; else if (editingStyle = UITableViewCellEditingStyleInsert) / Create a new instance of the appropria
22、te class, insert it into the array, and add a new row to the table view */*/ Override to support rearranging the table view.- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath */*/ Override to suppo
23、rt conditional rearranging of the table view.- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath / Return NO if you do not want the item to be re-orderable. return YES;*/#pragma mark - Navigation/ In a storyboard-based applic
24、ation, 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.
25、 ViewController *view = segue.destinationViewController; UITableViewCell *cell = self.tableView cellForRowAtIndexPath:self.tableView.indexPathForSelectedRow; UILabel *label = cell valueForKey:self.str; vi
26、ew.string = label.text; end#import "ViewController.h"interface ViewController ()endimplementation ViewController- (void)viewDidLoad super viewDidLoad; / Do any additional setup after loading the view. self.label.text = self.strin
27、g; - (void)didReceiveMemoryWarning super didReceiveMemoryWarning; / 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 navigat
28、ion- (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 _label release;
29、0; self.string = nil; super dealloc; end#import "ScrollCell.h"implementation ScrollCell- (void)awakeFromNib / Initialization code- (void)setSelected:(BOOL)selected animated:(BOOL)animated super setSelected:selected animated:animated;&
30、#160; / Configure the view for the selected state- (void)setValue:(id)value forUndefinedKey:(NSString *)key- (id)valueForUndefinedKey:(NSString *)key if (key isEqualToString:"gender") return ;
31、0; else return nil; - (void)dealloc _scrollimageView release; _name release; _type release; super dealloc; end#import "HerosCell.h"#import
32、"Person.h"implementation HerosCell- (void)setValueByPerson:(Person *)person self.pictureView.image = UIImage imageNamed:person.image; .text = ; self.gender.text = person.gender; self.type.text = per
33、son.type;- (void)awakeFromNib / Initialization code- (void)setSelected:(BOOL)selected animated:(BOOL)animated super setSelected:selected animated:animated; / Configure the view for the selected state- (void)dealloc _pictureView release; _name release; _g
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 三年级语文上册第八单元测试卷-基础知识与综合能力篇 含答案 部编版
- 2024建设工程合作合同范本
- 2024门面房出租合同范本门面房转让步骤及合同范本2
- 2024招投标购买合同书样本
- 规划课题申报范例:第二轮“双一流”建设绩效评价研究(附可修改技术路线图)
- 深圳大学《学前儿童家庭教育学》2022-2023学年第一学期期末试卷
- 北京健身合同(2篇)
- 商务公寓预售协议书(2篇)
- 关于班学期工作计划模板合集6篇
- 放射治疗核医学卫生监督
- 建筑公司组织架构及岗位职责
- COPD诊疗新进展
- 先进先出法与后进先出法ppt课件
- 精品资料(2021-2022年收藏的)病案管理制度全套
- 低压工作票(共3页)
- 2阀门结构和工作原理(上)
- 基础图案设计(课堂PPT)
- 食堂操作工艺流程图
- 玉米栽培品比试验-文档
- 幼儿园参观学校活动方案5篇
- 关于旅游景区游客满意度研究的文献综述
评论
0/150
提交评论