自定义tableViewCell 的复用问题
自定义了一个Cell继承UItableViewCell,在nib文件中拖入一个cell,把identifier改成了和cellForRowAtIndexPath方法里的复用标识符。
问题来了,我运行程序后,拖动cell,程序崩溃。报错-[UIImage isKindOfClass:]: message sent to deallocated instance 0x1d504c70
上代码:ChatCustomCell1.h
#import <UIKit/UIKit.h>
@interface ChatCustomCell1 : UITableViewCell
{
}
@property (retain, nonatomic) IBOutlet UIImageView *leftFaceImageView;
@property (retain, nonatomic) IBOutlet UIImageView *rigthFaceImageView;
@property (retain, nonatomic) IBOutlet UIImageView *messageBackImage;
@property (retain, nonatomic) IBOutlet UILabel *leftNameLable;
@property (retain, nonatomic) IBOutlet UILabel *rightNameLable;
@property (retain, nonatomic) IBOutlet UILabel *leftTimeLable;
@property (retain, nonatomic) IBOutlet UILabel *rightTimeLable;
@property (retain, nonatomic) IBOutlet UILabel *messageLable;
@end
#import "ChatCustomCell1.h"uitableviewcell 自定义Cell 复用
@implementation ChatCustomCell1
@synthesize leftFaceImageView=_leftFaceImageView;
@synthesize rigthFaceImageView=_rigthFaceImageView;
@synthesize messageBackImage=_messageBackImage;
@synthesize leftNameLable=_leftNameLable;
@synthesize rightNameLable=_rightNameLable;
@synthesize leftTimeLable=_leftTimeLable;
@synthesize rightTimeLable=_rightTimeLable;
@synthesize messageLable=_messageLable;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
@end
[解决办法]
应该把这个cellForRowAtIndexPath函数内容贴出来吧
[解决办法]
你报错的那块代码没贴出来啊 已经释放的实例你给它发方法了 你仔细看下
[解决办法]
这种一般都是 内存释放 的问题,而且,UITableVIew才有处理cell的委托方法。