0
我有圖像文件存儲在iphone文檔目錄中,當我給該圖像按鈕背景它不顯示。如何從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];
讓我知道如果你有一個有問題。 – user1673099
爲什麼說使用NSURL它簡單[UIImage imageWithContentsOfFile:img_path]; –