ドキュメントディレクトリに保存した最新のイメージを表示したいと思います。コードでドキュメントディレクトリから最新の保存されたイメージのみを読み込む方法はありますか?
私は最初、ImageData.plistにあるすべての画像をカウントし、その後、私は何か間違ったことをやっているので、それは、任意の画像が表示されない1.
を減算することにより、最新の画像を表示しようとしたの下に正確に何を把握することはできませんか?
Thxです。
- (void)viewDidLoad {
[super viewDidLoad];
//Show latest added image from document directory
//Add UIImageView
UIImageView *guideSheet = [[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)]autorelease];
//Add latest image
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *path = [documentsDirectory stringByAppendingPathComponent:@"ImageData.plist"];
NSArray *plistFile = [[NSArray alloc] initWithContentsOfFile:path];
NSInteger plistCount = [plistFile count];
for (NSInteger i = plistCount; i < (plistCount - 1); i++) {
// Show image
NSString *imageName = [NSString stringWithFormat:@"ImageData/ImageData%i.jpg", i];
UIImage* content = [UIImage imageWithContentsOfFile:imageName];
guideSheet.image = content;
[self.view addSubview:guideSheet];
}
[plistFile release];
}
使用した言語のタグを追加してもよろしいですか?ありがとう – reporter
私はXcode 4.2を使用しています。私はまだ初心者ですので、これが正しい情報であることを願っています:) – user997841