Earlier we use to compare two images by using isEquals(==) if both image object are using [UIImage imageNamed:@"abc.png"]. But in IOS 8 it is not working. is there any specific reason for that or we can do the same??
之前我们使用isEquals(==)比较两个图像,如果两个图像对象都使用[UIImage imageNamed:@“abc.png”]。但是在IOS 8中它没有用。有没有具体的原因,或者我们可以做同样的事情?
1 个解决方案
#1
0
Never and never use ==
to compare objects equality.
永远不要使用==来比较对象的平等性。
Here is a simple method, which will resolve your issue.
这是一个简单的方法,可以解决您的问题。
- (BOOL)image:(UIImage *)aImage1 equalsTo:(UIImage *)aImage2
{
NSData *img1Data = UIImageJPEGRepresentation(aImage1, 1.0);
NSData *img2Data = UIImageJPEGRepresentation(aImage1, 1.0);
return [img1Data isEqualToData:img2Data];
}
#1
0
Never and never use ==
to compare objects equality.
永远不要使用==来比较对象的平等性。
Here is a simple method, which will resolve your issue.
这是一个简单的方法,可以解决您的问题。
- (BOOL)image:(UIImage *)aImage1 equalsTo:(UIImage *)aImage2
{
NSData *img1Data = UIImageJPEGRepresentation(aImage1, 1.0);
NSData *img2Data = UIImageJPEGRepresentation(aImage1, 1.0);
return [img1Data isEqualToData:img2Data];
}