以下是我的代码:
UIImage *takePhotoImg = [UIImage imageNamed:@"add_pic.png"];
self.takePhoto = [[UIButton alloc] initWithFrame:CGRectMake(120, 100, takePhotoImg.size.width, takePhotoImg.size.height)];
[_takePhoto setImage:takePhotoImg forState:UIControlStateNormal];
[_takePhoto addTarget:self action:@selector(takePhotoBtn) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:_takePhoto];
当我使用分析时,它显示以下行:
[_takePhoto setImage:takePhotoImg forState:UIControlStateNormal];
分配的对象的潜在泄漏。我需要添加版本,还是忽略?
先感谢您
更新:我确实在我的 dealloc 中释放了按钮 _takePhoto:
-(void)dealloc
{
[_takePhoto release];
[super dealloc];
}
我的财产 :
@property(nonatomic,retain)UIButton *takePhoto;