600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > ios LOL 英雄联盟 英雄头像展示

ios LOL 英雄联盟 英雄头像展示

时间:2023-03-21 00:33:24

相关推荐

ios  LOL 英雄联盟  英雄头像展示

本项目主要是 使用 tableview 控件,使用 plist里所定义的 dictionary 格式文件 显示

// 通过 nsbundle 将 heros.plist 文件 取出到 一个 数组 array 里

NSString *file=[[NSBundle mainBundle] pathForResource:@"heros.plist" ofType:nil];NSArray *arraydic=[[NSArray alloc]initWithContentsOfFile:file];NSMutableArray *arraymut=[NSMutableArray arrayWithCapacity:arraydic.count];for(NSDictionary *dic in arraydic){Hero *hero=[Hero herowithdic:dic];[arraymut addObject:hero];}array=[arraymut copy];

//设置 tableview 里 的cell 样式

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{static NSString *identifier = @"cell";UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:identifier];if(!cell){UITableViewCell *cell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];}Hero *hero=self.array[indexPath.row]; // 设置 cell 的 附控件 样式 cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

cell.textLabel.text=hero.name;cell.detailTextLabel.text=hero.intro;cell.detailTextLabel.textColor = [UIColor orangeColor];cell.imageView.image=[UIImage imageNamed:hero.icon];return cell;}

// 调用方法 控制 导航控制栏 是否 隐藏

-(BOOL)prefersStatusBarHidden{return YES;}

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{if ([segue.identifier isEqual:@"show"]) {NSIndexPath *index= [self.tableview indexPathForSelectedRow];//NSLog(@"%d",index.row);Hero *hero=[self.array objectAtIndex:index.row];DetailView *de=segue.destinationViewController;

// 给第二个 view 传送 数据[de setValue:hero.intro forKey:@"strTitle"];}}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。