表示されないボタンの背景にその画像を指定したときに、iPhoneのドキュメントディレクトリに保存されている画像ファイルがあります。
NSString*imageThumbnailVideo= [NSString stringWithFormat:@"%@thumbVideo.png",imageThumbnail];
NSLog(@"imageThumbnailVide is %@",imageThumbnailVideo);
NSString * filePath = [NSString stringWithFormat:@"%@/Documents/%@", NSHomeDirectory(),imageThumbnailVideo];
BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:filePath];
if (fileExists == 0)
{
NSLog(@"File is Not exists");
}
else
{
NSLog(@"File is present");
}
[thumbnailImageView setBackgroundImage:[UIImage imageNamed:imageThumbnailVideo] forState:UIControlStateNormal];
また、ファイルが存在すると表示されますが、画像は表示されません。
これが私がファイルを保存する方法です
testT=[NSString stringWithFormat:@"%@thumbVideo",titleTextField.text];
NSString *newStringVT = [testT stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString*imageTitleVT=[NSString stringWithFormat:@"%@.png",newStringVT];
NSString *pathVT = [documentsDirectory stringByAppendingPathComponent:imageTitleVT];
NSData*thumbVideoData=UIImagePNGRepresentation(thumbnail);
NSError * error = nil;
[thumbVideoData writeToFile:pathVT options:NSDataWritingAtomic error:&error];