UIImage *image = [UIImage imageNamed: [NSString stringWithFormat:@"Photo.png"]];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
代替策として、dataWithContentsOfFileを使うとキャッシュを使わずに画像を表示することができる。
NSString *fileLocation = [[NSBundle mainBundle] pathForResource:@"Photo" ofType:@"png"];
NSData *imageData = [NSData dataWithContentsOfFile:fileLocation];
UIImage *image = [UIImage imageWithData:imageData];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
他の手法として、initWithContentsOfFileを使用する方法もある。
NSString *fileLocation = [[NSString alloc] init];
fileLocation = [[NSBundle mainBundle] pathForResource:@"Photo" ofType:@"png"];
UIImage* image = [[UIImage alloc] initWithContentsOfFile:fileLocation];
タグ:iPhone
【UIImageViewの最新記事】