当我在 iphone 上添加 thre 到四个图像内存后运行这个程序时,警告来了,应用程序崩溃了。所以请帮助我谢谢我只是获取图像参考并写入文件,然后从文件路径获取图像。谢谢
- (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];
}