SecondiosAppTutorial--学习笔记
2016-03-02 18:25
288 查看
自学SecondiosAppTutorial过半,运行程序报错了,最终问题找到,英文文档读起来很有挫败感,但耐心就能发现问题,Xcode的问题提示很明确清楚。如下:
tableView 没有返回值,cell 值为null。设计TableView的实现方法在MasterViewController.m中,先从代码着手找问题。
cell没有值,依次输出信息15、19输出内容都是null。那么第7行就很可能出错了。BirdSightingCell是 TableView中cell的Identifier的属性值,发现自己的表格中的值竟然是cell。恍然大悟。具体位置如下:
/*Debug 输出的报错信息,显示TableView cell为空值*/ *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
tableView 没有返回值,cell 值为null。设计TableView的实现方法在MasterViewController.m中,先从代码着手找问题。
1 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 2 /*UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; 3 4 NSDate *object = self.objects[indexPath.row]; 5 cell.textLabel.text = [object description]; 6 return cell;*/ 7 static NSString *CellIdentifier = @"BirdSightingCell";/*BirdSightingCell是表格中cell的Identifier属性名字*/ 8 9 static NSDateFormatter *formatter = nil; 10 if (formatter == nil) { 11 formatter = [[NSDateFormatter alloc] init]; 12 [formatter setDateStyle:NSDateFormatterMediumStyle]; 13 } 14 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 15 NSLog(@"111222%@",cell); 16 BirdSighting *sightingAtIndex = [self.dataController objectInListAtIndex:indexPath.row]; 17 [[cell textLabel] setText:sightingAtIndex.name]; 18 [[cell detailTextLabel] setText:[formatter stringFromDate:(NSDate *)sightingAtIndex.date]]; 19 NSLog(@"111222%@",cell); 20 return cell; 21 }
cell没有值,依次输出信息15、19输出内容都是null。那么第7行就很可能出错了。BirdSightingCell是 TableView中cell的Identifier的属性值,发现自己的表格中的值竟然是cell。恍然大悟。具体位置如下:
相关文章推荐
- Android高效加载大图、多图解决方案,有效避免程序OOM
- Access forbidden! You don't have permission to access the requested object. It is either read-protected or not readable by the server
- Android初试--Activit的简单介绍(1)
- swift- 优化照片 滤镜
- iOS证书
- IOS开发 多线程编程 - NSOperation
- iOS 在App内返回到指定页面
- Android中不显示标题
- Android Project Butter分析
- android superWebView ----新的 Hybrid App 解决方案(集成总结)
- ios 小问题,滑动tableview,导航出去,再回来会保持原样,但我想自动保持顶部
- iOS开发将支付宝导入到工程师出现的错误‘openssl/ asn1.h’file not found的解决方法
- android 百度地图画路线(驾车路线)
- android fragmeng在闪退或者出错时出现重叠
- android app如何做到快速启动
- 苹果开发者证书与发布证书显示:此证书的签发者无效
- 解决Error:Android Dex: com.android.dex.DexIndexOverflowException: Cannot merge new index 65918 into a
- Android学习笔记----Activity的生命周期
- Android 发短信功能实现
- IOS开发 多线程