在我的程序,當我創建一對夫婦從筆尖文件加載定製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