I suggest you 1. move backgroundImageView.hidden = !selected; to within - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event because it's not a good idea to manipulate UI in a data member's setter. 2. let system generate setter and getter for you.
c*g
4 楼
I moved the backgroundImageView.hidden = !selected to the touchesBegan: call . However, now the leaks instrument reports the touchesBegan is leaking. According to the report, the leaking statement is "backgroundImageView.hidden = !selected". That's why I am confused. I also posted this to Apple's developer forum. One guy mentioned if an object leaks, all its sub-objects will leak as well. But I just couldn't find out the root cause. Thanks anyway.
【在 S**********r 的大作中提到】 : I suggest you : 1. move backgroundImageView.hidden = !selected; : to within : - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event : because it's not a good idea to manipulate UI in a data member's setter. : 2. let system generate setter and getter for you.
i*o
5 楼
What happens when background image is shown or hidden, maybe once it is shown, some view will have a reference to it, and that guy is not releasing it. So basically follow the chain reaction caused by this call...