[ios专项]几个遗留问题dequeueReusableCellWithIdentifier_2014-05-29
来源:互联网 发布:英雄联盟 知乎 编辑:程序博客网 时间:2024/06/05 19:44
几个遗留的问题需要研究,先临时放在这里
dequeueReusableCellWithIdentifier
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier]; if (cell == nil) { cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CustomCellIdentifier];
翻译下面这段代码:
如下是:<pre code_snippet_id="368078" snippet_file_name="blog_20140529_2_5526610" name="code" class="objc">dequeueReusableCellWithIdentifier
的问题
#pragma mark -#pragma mark Table Data Source Methods- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.dataList count];}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CustomCellIdentifier = @"CustomCellIdentifier"; static BOOL nibsRegistered = NO; if (!nibsRegistered) { UINib *nib = [UINib nibWithNibName:@"CustomCell" bundle:nil]; [tableView registerNib:nib forCellReuseIdentifier:CustomCellIdentifier]; nibsRegistered = YES; } CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CustomCellIdentifier]; if (cell == nil) { cell = [[CustomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CustomCellIdentifier]; } NSUInteger row = [indexPath row]; NSDictionary *rowData = [self.dataList objectAtIndex:row]; cell.name = [rowData objectForKey:@"name"]; cell.dec = [rowData objectForKey:@"dec"]; cell.loc = [rowData objectForKey:@"loc"]; cell.image = [imageList objectAtIndex:row]; return cell;}#pragma mark Table Delegate Methods- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { return 60.0;}- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { return nil;}
如下是:<pre name="code" class="objc">bundle URLForResource的问题
<pre name="code" class="objc">//加载plist文件的数据和图片 NSBundle *bundle = [NSBundle mainBundle]; NSURL *plistURL = [bundle URLForResource:@"friendsInfo" withExtension:@"plist"]; NSDictionary *dictionary = [NSDictionary dictionaryWithContentsOfURL:plistURL]; NSMutableArray *tmpDataArray = [[NSMutableArray alloc] init]; NSMutableArray *tmpImageArray = [[NSMutableArray alloc] init]; for (int i=0; i<[dictionary count]; i++) { NSString *key = [[NSString alloc] initWithFormat:@"%i", i+1]; NSDictionary *tmpDic = [dictionary objectForKey:key]; [tmpDataArray addObject:tmpDic]; NSString *imageUrl = [[NSString alloc] initWithFormat:@"%i.png", i+1]; UIImage *image = [UIImage imageNamed:imageUrl]; [tmpImageArray addObject:image]; } self.dataList = [tmpDataArray copy]; self.imageList = [tmpImageArray copy];
0 0
- [ios专项]几个遗留问题dequeueReusableCellWithIdentifier_2014-05-29
- iOS 遗留问题
- 遗留问题
- 遗留问题
- 遗留问题
- 遗留问题
- 遗留问题
- 遗留问题
- 遗留问题
- iOS 性能专项初探
- IOS专项测试instruments
- [ios专项]TableView 全面介绍 资料整理
- IOS APP启动优化-专项优化
- 今晚遗留问题
- 遗留问题汇总
- softwarekeyboard遗留问题
- 项目遗留问题
- 项目遗留问题
- ubuntu系统安装FTP
- 安装Gitolite的汇总
- 自定义持久层(dao)框架
- Linux软件的卸载
- 1061找规律法
- [ios专项]几个遗留问题dequeueReusableCellWithIdentifier_2014-05-29
- 学习笔记之 DBUtils 组件
- linux 通用时钟框架CCF
- node和npm的安装
- npm命令
- GridView的监听,选择,美化等详解
- 腾讯云服务器,给力来袭,,开发者扶持计划,,最高1000元的代金券..
- AdapterView、Adapter深度学习
- 入门指南--grunt学习笔记(1)