My problem is: I setted up an iAP in my app and when the user taps on a button it ask him "would you like to buy this". However, I have a image and a backround image placed on the button. I have this code implementet, that if the user hast bought the item the image of the button, which is a lock icon disappears. It works on the simulator fine, but on the device I am able to buy the item but the lock icon doesnt appears at all. Even if I havent bought the item theres no lock icon. On the simulator there's a lock item, if the item wasnt bought. I use the BOOL
in my .h file: -(BOOL)IAPItemPurchased;
and in the .m file I use the IAPItemPurchased to hide the foreground image, in my viewDidLoad
:
- (void)viewDidLoad
{
[super viewDidLoad];
if ([self IAPItemPurchased]) {
[buy setImage:nil forState:UIControlStateNormal];
} else {
[buy setImage:[UIImage imageNamed:@"Lock.png"] forState:UIControlStateNormal];
}
}
Does have anyone suggestions or solutions what to do?
Thanks for help.
Kindly Check the Image Name, because In Simulator the Name of image is Case Insensitive , but Device it is case sensitive .
( or )
- (void)viewDidLoad
{
[super viewDidLoad];
if ([self IAPItemPurchased]) {
[buy setImage:[UIImage imageNamed:nil] forState:UIControlStateNormal];
} else {
[buy setImage:[UIImage imageNamed:@"Lock.png"] forState:UIControlStateNormal];
}}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.