ファイルシステムからUIImageView
ビューにロードしている透明な画像がいくつかあります。私の目的のためにUIImageView
、ファイルシステム上のファイルと画像を比較する必要があります。だから私は次のようなことをします:
NSString *directoryPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *imageFile = [NSString stringWithFormat:@"%@/image.png", directoryPath];
if ([[NSData dataWithContentsOfFile:imageFile] isEqualToData:UIImagePNGRepresentation([imageView image])]) {
NSLog(@"Equal");
} else {
NSString *dataDescription = [[[NSData dataWithContentsOfFile:feltFile] description] substringToIndex:100];
NSString *imageDescription = [[UIImagePNGRepresentation([backgroundImageView image]) description] substringToIndex:100]
NSLog(@"Unequal: %@ %@", dataDescription, imageDescription);
}
私はそれらがPNG画像であることを知っています。印刷すると、どちらの説明もNULLになりません。しかし、それらは不平等です。
なぜこうなった?