zoukankan      html  css  js  c++  java
  • 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"]; } }

      

  • 相关阅读:
    BeautifulSoup中的select方法
    BeautifulSoup中的find,find_all
    python中sys.stdout、sys.stdin
    python sort、sorted
    Numpy常用操作
    pandas (loc、iloc、ix)的区别
    小波变化库——Pywalvets学习笔记
    python filter()函数
    Redis数据库总结
    高逼格企业级MySQL数据库备份方案,原来是这样....
  • 原文地址:https://www.cnblogs.com/stuwan/p/4376330.html
Copyright © 2011-2022 走看看