如何比较iOS 8中的两个UIImage [英] How to compare two UIImage in iOS 8
本文介绍了如何比较iOS 8中的两个UIImage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用下面给出的方法
IBOutlet UIImageView * imgViewCheck;
IBOutlet UIImageView *imgViewCheck;
- (IBAction)clkCheckUncheck:(id)sender {
if (imgViewCheck.image == [UIImage imageNamed:@"uncheck.png"]) {
imgViewCheck.image = [UIImage imageNamed:@"check.png"];
} else {
imgViewCheck.image = [UIImage imageNamed:@"uncheck.png"];
}
}
它适用于iOS7但不工作iOS8
It is working in up to iOS7 but not working in iOS8
推荐答案
请比较NSData对象而不是比较UIImage对象。
Please compare NSData object instead of comparing UIImage Object.
-(BOOL)firstimage:(UIImage *)image1 isEqualTo:(UIImage *)image2 {
NSData *data1 = UIImagePNGRepresentation(image1);
NSData *data2 = UIImagePNGRepresentation(image2);
return [data1 isEqualToData:data2];
}
这篇关于如何比较iOS 8中的两个UIImage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文