Reputation:
I have 4 cards and I can flip my cards, I want to check if my images is the same show 2 images and if it's not back the flip,
would you please give me some tutorial or sample code;
Thanks in advance!
Edit:
Here is my images:
UIImage *img1 = [UIImage imageNamed:@"card_front.png"];
[self addCardAtX:90 y:120 andFrontImage:img1 andTag:1];
[self addCardAtX:230 y:120 andFrontImage:img1 andTag:1];
[self addCardAtX:90 y:340 andFrontImage:img1 andTag:1];
[self addCardAtX:230 y:340 andFrontImage:img1 andTag:1];
- (void)addCardAtX:(CGFloat)x y:(CGFloat)y andFrontImage:(UIImage *) img1 andTag:(int)tag
{
UIImage *img2= [UIImage imageNamed:@"card_back.png"];
CardView *cv = [[CardView alloc] initWithFrontImage:img1 backImage:img2];
CGRect f = cv.frame;
f.origin.x = x-(f.size.width/2.0);
f.origin.y = y-(f.size.height/2.0);
cv.frame = f;
[self.view addSubview:cv];
}
Upvotes: 0
Views: 565
Reputation: 47049
You can Compare image by its NAME or URL/Path But in objective-c you can also compare two objects, By,
if ([object1 isEqual:object2])
take BOOL variable imgCompare=NO; and check condition
if([Imgobject1 isEqual:ImgObject2])
imgCompare=YES;
else
imgCompare=NO;
Here is best Question of related discussion and also check This Link.
Thanks :)
Upvotes: 1
Reputation: 77631
You can check if images are equal buy using...
BOOL imagesAreTheSame = [image1 isEqual:image2];
Upvotes: 0