[ios专项]几个遗留问题dequeueReusableCellWithIdentifier_2014-05-29
2014-05-29 01:34
316 查看
几个遗留的问题需要研究,先临时放在这里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:UITableViewCellStyleDefaultreuseIdentifier: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 *)tableViewwillSelectRowAtIndexPath:(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];
相关文章推荐
- iOS-UITableView的两种重用Cell方法的区别(dequeueReusableCellWithIdentifier)
- IOS-dequeueReusableCellWithIdentifier的应用
- iOS-UITableView的两种重用Cell方法的区别(dequeueReusableCellWithIdentifier)
- (0069)iOS开发之dequeueReusableCellWithIdentifier的两个方法的区别
- UITableView 关于dequeueReusableCellWithIdentifier的问题
- dequeueReusableCellWithIdentifier:和dequeueReusableCellWithIdentifier: forIndexPath:的问题
- iOS 运行出现:Assertion failure in -[UITableView dequeueReusableCellWithIdentifier:forIndexPath:], /Sourc
- iOS 坑点 Assertion failure in - UITableView dequeueReusableCellWithIdentifier:forIndexPath:
- IOS 使用storyboard,自定义TableViewCell的坑,dequeueReusableCellWithIdentifier 报错
- iOS dequeueReusableCellWithIdentifier: forIndex: 与dequeueReusableCellWithIdentif比较
- dequeueReusableCellWithIdentifier方法问题
- iOS学习之—— dequeueReusableCellWithIdentifier
- iOS 关于UITableView的dequeueReusableCellWithIdentifier
- [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]IOS6.0以上
- dequeueReusableCellWithIdentifier的理解
- 关于TableViewCell生成时dequeueReusableCellWithIdentifier的认识
- dequeueReusableCellWithIdentifier
- dequeueReusableCellWithIdentifier的运行机制
- dequeueReusableCellWithIdentifier
- 关于TableViewCell生成时dequeueReusableCellWithIdentifier的认识