【问题标题】:check the same images after flip cards (objective-C)翻转卡片后检查相同的图像(目标-C)
【发布时间】:2013-01-29 14:34:20
【问题描述】:

我有 4 张卡片,我可以翻转卡片,我想检查我的图像是否相同显示 2 张图像,如果不是后翻转,

能给我一些教程或示例代码吗?

提前致谢!

编辑:

这是我的图片:

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];
}

【问题讨论】:

  • 是的,使用图片以外的其他东西。你想做的事情很难。使用标签或其他东西。
  • @adam:标签越多,看到的人就越多。更多答案,快速答案,超级答案。
  • @AKV 感谢您的建议
  • @Fogmeister 你知道任何教程吗?获取卡片图片并进行比较
  • 否,但大概您有一些代码表示特定卡的“加载图像 x”或“加载图像 y”。那么使用这些信息来查看卡片是否匹配,而不是图像。

标签: ios objective-c ipad cocoa nsimage


【解决方案1】:

您可以通过名称或网址/路径比较图片 但是在objective-c中你也可以比较两个对象,By,

if ([object1 isEqual:object2])

取 BOOL 变量 imgCompare=NO;并检查条件

if([Imgobject1 isEqual:ImgObject2])
  imgCompare=YES;
else
  imgCompare=NO;

这里是最好的Question of related discussion 并检查This Link.

谢谢:)

【讨论】:

    【解决方案2】:

    您可以检查图像是否相等购买使用...

    BOOL imagesAreTheSame = [image1 isEqual:image2];
    

    【讨论】:

      猜你喜欢
      • 2017-04-03
      • 1970-01-01
      • 2021-03-12
      • 1970-01-01
      • 2023-03-30
      • 2013-01-07
      • 2014-01-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多