在我的程序,当我创建一对夫妇从笔尖文件加载定制UIViewCells的:EXC_BAD_ACCESS滚动的TableView
[[NSBundle mainBundle] loadNibNamed:@"CustomCells" owner:self options:nil];
一旦他们加载我设置起来,并从函数返回:
if (indexpath.row == 1) {
[nibTextInputer setupWithName:@"notes" ...];
return nibTextInputer;
} else {
[nibSelectInputer setupWithName:@"your_choice" ...];
return nibSelectInputer;
};
其中nibTextInputer是我的班级(AFTextInputer)和nibSelectInputer是我的其他班级(AFTextInputer)。这两个类都来自UITableViewCell的子类。
这一切工作正常,但休息时,我添加缓存到:
Boolean inCache = false;
if (indexPath.row == 1) {
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"nibTextInputer"];
if (cell != nil) {
NSLog(@"%@", [cell description]); // prints out ok, correct type.
nibTextInputer = (AFTextInputer*) cell;
inCache = true;
};
};
if (!inCache) {
[[NSBundle mainBundle] loadNibNamed:@"CustomCells" owner:self options:nil];
}
一旦我添加上面EXC_BAD_ACCESS开始出现在随机的地方,通常没有额外的信息,有时与此错误:
-[CALayer prepareForReuse]: unrecognized selector sent to instance
甚至
-[UIImage prepareForReuse]: unrecognized selector sent to instance
EXC_BAD_ACCES的位置S看起来是随机的。有时,它的“出列”之后,有时是郊外的功能..
我想这个问题就在于我的实现定制UIViewCells之内,但我不知道从哪里开始寻找..
想法?
这就是..CellWithIdentifier:用于 - 标识符(“nibTextInputer”)在nib文件中设置,并且我通过NSLogging单元格类型进行双重检查。 – kolinko 2010-09-08 17:25:10
我不知道有什么区别wetween布尔和布尔..我会研究,谢谢。 – kolinko 2010-09-08 17:25:44