学习表视图(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滑动时报错的更多相关文章

  1. 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 ...

  2. 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: ") ...

  3. mybatis批量插入oracle时报错:unique constraint (table name) violated

    mybatis批量插入oracle时报错:unique constraint (table name) violated,是因为插入的集合中有两条相同唯一约束的数据.

  4. 制作一个可以滑动操作的 Table View Cell

    本文转载至 https://github.com/nixzhu/dev-blog Apple 通过 iOS 7 的邮件(Mail)应用介绍了一种新的用户界面方案——向左滑动以显示一个有着多个操作的菜单 ...

  5. db2的select语句在db2 client上执行正确,JDBC连接数据库时报错

    db2的select语句在db2 client上执行正确,JDBC连接数据库时报错. sql语句是:select ...from QUALIFIER.tableName fetch first 21 ...

  6. sql server中NULL导入decimal字段时报错

    sql server中NULL导入decimal字段时报错 在导入CSV文件时,如果decimal字段为null值,导致文本文件入库时失败. 错误现象 构造例子 新建一张表,包含decimal字段. ...

  7. mysql数据库导出时报错mysqldump: Got error: 145的解决方法

      在给mysql数据库备份时,报错:mysqldump: Got error: 145: Table './jxzhtopenfire/ofoffline' is marked as crashed ...

  8. 【转载】Mysql创建表时报错error150

    从mysql数据库中导出正常数据库的脚本语句,而后使用脚本语句创建数据库的过程中,执行语句提示Can't Create Table 'XXX' erro150的错误,语句执行中断,创建table失败, ...

  9. [Android] Android Build 时报错: java.io.IOException: Could not parse XML from android/accounts/annotations.xml

    Android构建时报错: app:lintVitalRelease[Fatal Error] :3:214: 与元素类型 “item” 相关联的 “name” 属性值不能包含 ‘<’ 字符. ...

随机推荐

  1. Linux-以指定用户运行redis

    redis中无配置启动用户信息,需要添加redis用户,后以其启动 useradd -s /bash/false -M redis >& &

  2. Python-事件驱动模型代码

    #/usr/env/bin python ''' this is document ''' class Event(object): ''' 事件初始化的一个方式 ''' def __init__(s ...

  3. Viewpager图片自动轮播,网络图片加载,图片自动刷新

    package com.teffy.viewpager; import java.util.ArrayList; import java.util.concurrent.Executors; impo ...

  4. [Programming Entity Framework] 第3章 查询实体数据模型(EDM)(一)

    http://www.cnblogs.com/sansi/archive/2012/10/18/2729337.html Programming Entity Framework 第二版翻译索引 你可 ...

  5. Java小陷阱

    基本数据类型与字符串的连接 在Java中,+不仅可作为加法运算符使用,还可作为字符串连接运算符使用. 当把任何基本数据类型的值与字符串值进行连接运算时,基本类型的值将自动类型转换为字符串类型. pub ...

  6. java生成随机字符串uuid

    GUID是一个128位长的数字,一般用16进制表示.算法的核心思想是结合机器的网卡.当地时间.一个随即数来生成GUID.从理论上讲,如果一台机器每秒产生10000000个GUID,则可以保证(概率意义 ...

  7. 在网页标题栏上和收藏夹显示网站logo

    第一步,准备一个图标制作软件. 首先您必须了解所谓的图标(Icon)是一种特殊的图形文件格式,它是以.ico 作为扩展名.普通的图像设计软件无法使用这种格式,所以您需要到下载一个ico图标工具,本站常 ...

  8. POJ #2479 - Maximum sum

    Hi, I'm back. This is a realy classic DP problem to code. 1. You have to be crystal clear about what ...

  9. Windows Server 2008 - How to Move the Quorum Disk Group

    I received this question from a friend the other day - asking how on a Windows Server 2008 cluster y ...

  10. GR&R

    ANOVA gauge R&R (or ANOVA gauge repeatability and reproducibility) is a measurement systems anal ...