下载此文档

iOS开发UI篇—UITableview控件基本使用.docx


文档分类:IT计算机 | 页数:约12页 举报非法文档有奖
1/12
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/12 下载此文档
文档列表 文档介绍
1 #import <Foundation/> 23 ***@interface NJHero : NSObject 4 /** 5*头像 6 */ 7 ***@property (nonatomic, copy) NSString *icon; 8 /** 9*名称 10 */ 11 ***@property (nonatomic, copy) NSString *name; 12 /** 13*描述 14 */ 15 ***@property (nonatomic, copy) NSString *intro; 16 17- (instancetype)initWithDict:(NSDictionary *)dict; 18+ (instancetype)heroWithDict:(NSDictionary *)dict; 19 ***@end 文件代码 1 #import "" 2 #import "" 34 ***@interface NJViewController ()<UITableViewDataSource, UITableViewDelegate> 5 /** 6*保存所有的英雄数据 7 */ 8 ***@property (nonatomic, strong) NSArray *heros; 9 ***@property (weak, nonatomic) IBOutlet UITableView *tableView; 10 11 ***@end 12 13 ***@implementation NJViewController 14 15 #pragma mark -懒加载 16- (NSArray *)heros 17{ 18 if (_heros == nil) { 19 // 20 NSString *fullPath = [[NSBundle mainBundle] pathForResource: @"heros" ofType: @"plist" ]; 21 // 22 NSArray *dictArray = [NSArray arrayWithContentsOfFile:fullPath]; 23 // 24 NSMutableArray *models = [NSMutableArray arrayWithCapacity:]; 25 for (NSDictionary *dict in dictArray) { 26 NJHero *hero = [NJHero heroWithDict:dict]; 27 [models addObject:hero]; 28} 29 // 30 _heros = [models copy]; 31} 32 // 33 return _heros; 34} 35 36-( void )viewDidLoad 37{ 38 [super viewDidLoad]; 39 //设置 Cell 的高度 40 //当每一行的 cell 高度一致的时候使用属性设置 cell 的高度 41 = 60; 42 . delegate = self; 43} 44 45 #pragma mark - UITableViewDataSource 46 //返回多少组 47- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 48{ 49 return 1; 50} 51 //返回每一组有多少行 52- (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 53{ 54 return ; 55} 56 //返回哪一组的哪一行显示什么内容 57- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 58{ 59 // CELL 60 UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifi

iOS开发UI篇—UITableview控件基本使用 来自淘豆网m.daumloan.com转载请标明出处.

非法内容举报中心
文档信息
  • 页数12
  • 收藏数0 收藏
  • 顶次数0
  • 上传人beny00011
  • 文件大小258 KB
  • 时间2016-09-03
最近更新