很抱歉,如果它已经被问过,但问题来了:
当我快速滚动 tableView 时收到此消息:
由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIImageView setText:]: unrecognized selector sent to instance 0x8a8f8d0”
这是我的代码:
NewsVideoCell *cell = [tableView dequeueReusableCellWithIdentifier:AudioCellIdentifier];
if (cell == nil) {
cell = [[NewsVideoCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:AudioCellIdentifier];
}
cell.backgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];
cell.selectedBackgroundView = [ [UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"news_bg"] resizableImageWithCapInsets:UIEdgeInsetsMake(10, 0, 10, 0)] ];
UILabel *cellLabel = (UILabel *)[cell viewWithTag:1];
[cellLabel setText:[masjid objectForKey:@"name"]];
UILabel *cellDate = (UILabel *)[cell viewWithTag:2];
[cellDate setText:[[news objectAtIndex:indexPath.row] objectForKey:@"date"]];
UIImageView *cellImage = (UIImageView *)[cell viewWithTag:3];
NSString *imagePath = [masjid objectForKey:@"thumb"];
[cellImage setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@", imagePath]]];
UITextView *cellText = (UITextView *)[cell viewWithTag:5];
NSString *postText = [[news objectAtIndex:indexPath.row] objectForKey:@"title"];
[cellText setText:postText];
...
触发此异常的行是:
[cellText setText:postText];
我看到这是由于过度保留或释放不足,但我没有找到解决方法。
有什么帮助吗?