Table View滑动时报错
学习表视图(Table View)的应用时,自己写了个demo,最后表格出来了,可是滑动时报错了,报错如下:

这是我ViewController.m部分的代码:
#import "ViewController.h" @interface ViewController () @end @implementation ViewController
{
NSArray *tableData;
} - (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
tableData = [NSArray arrayWithObjects:@"Egg Benedict" , @"Mushroom Risotto" , @"Full Breakfast" , @"Hamburger" ,@"Ham and Egg Sandwich" , @"Creme brelee" , @"white chocolate donut" , @"starbucks coffee" , @"vegetable curry" , @"instant noodle with egg" , @"noodle with bbq pork" , @"japanese noodle" , @"green tea" , @"thai shrimp cake" , @"angry birds cake" , @"ham and cheese panini" , nil];
//[tableData retain]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"SimpleTableItem"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier]; if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
} //[[cell textLabel] setText:[tableData objectAtIndex:[indexPath row]]];
cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:@"icon.png"]; return cell; } - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end
经过反复的测试后,解决办法如下:
在第17行加上:
[tableData retain];
这样就可以解决报错问题了。
Table View滑动时报错的更多相关文章
- vue使用swiper模块滑动时报错:[Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for example becaus
报错: vue报这个错 [Intervention] Ignored attempt to cancel a touchmove event with cancelable=false, for ex ...
- layui表格数据渲染SpringBoot+Thymeleaf返回的数据时报错(Caused by: org.attoparser.ParseException: Could not parse as expression: ")
layui table渲染数据时报错(Caused by: org.attoparser.ParseException: Could not parse as expression: ") ...
- mybatis批量插入oracle时报错:unique constraint (table name) violated
mybatis批量插入oracle时报错:unique constraint (table name) violated,是因为插入的集合中有两条相同唯一约束的数据.
- 制作一个可以滑动操作的 Table View Cell
本文转载至 https://github.com/nixzhu/dev-blog Apple 通过 iOS 7 的邮件(Mail)应用介绍了一种新的用户界面方案——向左滑动以显示一个有着多个操作的菜单 ...
- db2的select语句在db2 client上执行正确,JDBC连接数据库时报错
db2的select语句在db2 client上执行正确,JDBC连接数据库时报错. sql语句是:select ...from QUALIFIER.tableName fetch first 21 ...
- sql server中NULL导入decimal字段时报错
sql server中NULL导入decimal字段时报错 在导入CSV文件时,如果decimal字段为null值,导致文本文件入库时失败. 错误现象 构造例子 新建一张表,包含decimal字段. ...
- mysql数据库导出时报错mysqldump: Got error: 145的解决方法
在给mysql数据库备份时,报错:mysqldump: Got error: 145: Table './jxzhtopenfire/ofoffline' is marked as crashed ...
- 【转载】Mysql创建表时报错error150
从mysql数据库中导出正常数据库的脚本语句,而后使用脚本语句创建数据库的过程中,执行语句提示Can't Create Table 'XXX' erro150的错误,语句执行中断,创建table失败, ...
- [Android] Android Build 时报错: java.io.IOException: Could not parse XML from android/accounts/annotations.xml
Android构建时报错: app:lintVitalRelease[Fatal Error] :3:214: 与元素类型 “item” 相关联的 “name” 属性值不能包含 ‘<’ 字符. ...
随机推荐
- Abdicate
每次,打开背单词软件,背诵单词时,A打头的单词,第一个,永远会是 Abdicate,放弃,抛弃. 真是有意思. 想想在学习js高级程序设计一书时,一横心,决心手动输入书中出现过的每一个代码片段示例. ...
- data pump (数据抽取)测试
背景介绍>利用db_link直接pump抽取,减少转储文件集. 前提: 授权> grant create public database link,create database l ...
- Singleton模式
Singleton模式的特点: 保证一个类仅有一个实例,并提供一个访问它的全局访问点. 定义一个Instance操作,允许客户访问它的唯一实例.Instance是一个类操作(C++中的一个静态成员函数 ...
- 20150826运算符,if语句
运算符+ - * / % 加减乘除与注意:1.做除法运算时,如果两个操作数同为整数,则运算结果也是整数,不会出现小数.2.上面这些运算,如果两个操作数不同是一个类型,在运算的时候会自动进行类型转换. ...
- System.Web.HttpContext.Current 跟踪分析
public static HttpContext Current { get { return ContextBase.Current as HttpContext; } set { Context ...
- HOCON 了解
Spec This is an informal spec, but hopefully it's clear. Goals / Background The primary goal is: kee ...
- 添加和删除节点(HTML 元素)。
JavaScript HTML DOM 元素(节点) 添加和删除节点(HTML 元素). 创建新的 HTML 元素 如需向 HTML DOM 添加新元素,您必须首先创建该元素(元素节点),然后向一 ...
- python之路之正则表达式
匹配格式^ 匹配字符串的开头$ 匹配字符串的结尾. 除了换行符外的所有字符[...] 用来表示一组字符,,单独列出:[amk]匹配'a','m'或'k'[^..] 不在[]中的字符:[^abc]匹配除 ...
- uml类关系
类间的关系:http://www.open-open.com/lib/view/open1328059700311.html 泛化 . 实现 . 关联 . 组合 . 聚合 . 依赖 泛化是继承类,实现 ...
- Some thoughts on a progress
I can feel that I am making great progress now.. if inspected closely, it is obvious that what I'm g ...