0
我想在此位置創建圖像:無法從特定目錄顯示圖像IOS
NSString *documentsCacheDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *fileName = @"image1.jpg";
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsCacheDirectory, fileName];
所以適用於我的形象:
UIImage *myImage = [UIImage imageNamed:filePath];
..setting此圖像作爲背景我的按鈕等等。
但我沒有看到任何圖像顯示。然而,當我使用同樣的技術來讀取文件:
NSString *documentsCacheDirectory = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
NSString *fileName = @"file.txt";
NSString *filePath = [NSString stringWithFormat:@"%@/%@", documentsCacheDirectory, fileName];
NSString *fileContents = [[NSString alloc] initWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
for (NSString *line in [cacheFileContents componentsSeparatedByString:@"\n"]) {
.....
}
閱讀文件工作得很好,但圖像沒有任何理由?
謝謝,它的工作原理,我會盡快接受你的回答 – London 2012-03-13 15:34:26