版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年福建省泉州信息工程学院招聘参考题库附答案
- 2025广东茂名市高州市公益性岗位招聘1人备考题库(第五批1人)附答案
- 2025年宿州市第一人民医院社会化用人使用周转池编制89名笔试备考题库附答案
- AI赋能个性化学习:实践应用与案例解析
- 2026四川天府银行攀枝花分行春季社会招聘笔试备考题库及答案解析
- 2025秋人教版道德与法治八年级上册第三单元单元思考与行动同步练习
- 2026福建泉州市安溪县司法局招聘4人笔试备考题库及答案解析
- 北京市海淀区学府幼儿园招聘笔试备考试题及答案解析
- 2026湖南长沙市中医康复医院编外合同制人员招聘2人笔试备考题库及答案解析
- 2026湖南长沙市开福区清水塘实验学校春季公开招聘教师6人笔试参考题库及答案解析
- 2026年中化地质矿山总局浙江地质勘查院招聘备考题库及1套完整答案详解
- 护理部年度述职报告
- 2026青海果洛州久治县公安局招聘警务辅助人员30人笔试模拟试题及答案解析
- 2026年高考全国一卷英语真题试卷(新课标卷)(+答案)
- 湖南名校联考联合体2026届高三年级1月联考数学试卷+答案
- 2025-2030中国环保产业市场动态及投资机遇深度分析报告
- 山东省烟台市芝罘区2024-2025学年三年级上学期期末数学试题
- GB/T 6074-2025板式链、连接环和槽轮尺寸、测量力、抗拉载荷和动载载荷
- 护理员职业道德与法律法规
- 2025年安徽省普通高中学业水平合格性考试化学试卷(含答案)
- 2025年宁波市公共交通集团有限公司下属分子公司招聘备考题库及答案详解参考
评论
0/150
提交评论