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"]; } }

  

转载于:https://www.cnblogs.com/stuwan/p/4376330.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值