UITableView-03LOL英雄
来源:互联网 发布:动作电影推荐 知乎 编辑:程序博客网 时间:2024/04/29 17:46
实现如下界面
注意点:
- 在StroryBoard中拖线,设置tableView的数据源
- 不要把UITableViewDataSource写出UITableViewDelegate
- 添加图片资源和plist到Assets.xcassets
资源地址:度云 链接: http://pan.baidu.com/s/1pLAaRlL 密码: hqau
ViewController.m 源文件
//// ViewController.m// LOL英雄-单组数据//// Created by Kavee DJ on 16/5/13.// Copyright © 2016年 Kavee DJ. All rights reserved.//#import "ViewController.h"#import "KDJHero.h"@interface ViewController () <UITableViewDataSource>@property (nonatomic, strong) NSArray *heroes;@end@implementation ViewController// 懒加载- (NSArray *)heroes{ if (_heroes == nil) { // 加载plist中的字典数组 NSString *path = [[NSBundle mainBundle] pathForResource:@"heroes.plist" ofType:nil]; NSArray *dictArray = [NSArray arrayWithContentsOfFile:path]; // 字典数组 -> 模型数组 NSMutableArray *heroArray = [NSMutableArray array]; for (NSDictionary *dict in dictArray) { KDJHero *hero = [KDJHero heroWithDict:dict]; [heroArray addObject:hero]; } _heroes = heroArray; } return _heroes;}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}#pragma mark - <UITableViewDataSource>// 默认就是1组//- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView//{// return 1;//}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return self.heroes.count;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil]; // 取出每一行对应的数据模型 KDJHero *hero = self.heroes[indexPath.row]; cell.textLabel.text = hero.name; cell.imageView.image = [UIImage imageNamed:hero.icon]; cell.detailTextLabel.text = hero.intro; return cell;}@end
0 0
- UITableView-03LOL英雄
- UITableView之LOL英雄展示
- lol英雄列表显示
- LOL英雄英文名字
- lol英雄联盟解封
- 猫猫学IOS(十二)UI之UITableView学习(上)LOL英雄联盟练习
- (素材源码) 猫猫学IOS(十二)UI之UITableView学习(上)LOL英雄联盟练习
- AJ学IOS(12)UI之UITableView学习(上)LOL英雄联盟练习
- lol英雄背景小故事
- LOL英雄联盟搞笑段子
- lol-登陆英雄联盟出错
- lol-登陆英雄联盟出错
- Lol(英雄联盟)自动输入密码
- LOL Assistant英雄联盟挂机升级使用说明
- 英雄联盟(LOL)3d模型显示
- lol的英雄你会玩几个
- 视频:【LOL撸啊撸】《英雄联盟》Top
- LOL英雄联盟,新人最值得玩的英雄
- window system()函数的使用总结
- 设计模式总结之命令模式
- hadoop2.0集群版本在线升级方法
- Android高阶UI之CountdownView
- 百炼 1062:昂贵的聘礼
- UITableView-03LOL英雄
- ACM 数论 兔子的烦恼(一)
- Android项目重构之路:界面篇
- spring配置bean作用域
- Adapter中的getItem方法
- Android : 巧用RadioGroup作为Tab切换的按钮
- 安卓系统键盘弹出后不压缩控件大小
- 关于android无线连接的问题
- 数据库记录模拟器——DataEmulator