3つから4つの画像メモリを追加した後にiPhoneでこのプログラムを実行すると、警告が表示され、アプリがクラッシュします。助けてくださいありがとう、画像参照を取得してファイルに書き込み、ファイルパスから画像を取得するだけです。ありがとう
- (IBAction)addPicsButtonClick:(id)sender
{
UIImagePickerController * picker = [[[UIImagePickerController alloc] init] autorelease];
picker.delegate = self;
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
[self presentModalViewController:picker animated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *pathToDocuments=[paths objectAtIndex:0];
AppDelegate *app = [[UIApplication sharedApplication] delegate];
NSData *imageData = UIImageJPEGRepresentation([info objectForKey:@"UIImagePickerControllerOriginalImage"], 0.3f);
[imageData writeToFile:[NSString stringWithFormat:@"%@/%d.jpg", pathToDocuments, [app.images count]] atomically:YES];
[self dismissModalViewControllerAnimated:YES];
}