我们在 init 方法中创建了按钮,我们创建了两个 Uiimage 对象并创建了 Boolean
if(!isHint)
{
[hintBtn setImage:hintBtnImage forState:UIControlStateNormal];
}
else
{
[hintBtn setImage:hintBtnImagex forState:UIControlStateNormal];
}
hintBtn =[[UIButton alloc]initWithFrame:CGRectMake(794, 144, hintBtnImage.size.width, hintBtnImage.size.height)];
[hintBtn setImage:hintBtnImage forState:UIControlStateNormal];
[hintBtn addTarget:self action:@selector(showHint) forControlEvents:UIControlEventTouchUpInside];
当用户点击 tableview 单元格时,我们会更改布尔变量并设置图像。就像下面的代码
if(wrongx==1)
{
NSLog(@"the wrong x is %i",wrongx);
isHint = NO;
[hintBtn setImage:hintBtnImage forState:UIControlStateNormal];
}
但是当我第一次点击应用程序时它正在工作但第二次我收到以下错误
[UIImage retain]: message sent to deallocated instance
请回复我的帖子。在此先感谢