i try to save a photo from camera after take a photo with a button .
here is my codes:
-(IBAction)savePhoto{
    UIImageWriteToSavedPhotosAlbum(开发者_如何学Cimg.image, nil, nil);    
}
-(IBAction)takePic {
    ipc = [[UIImagePickerController alloc]init];
    ipc.delegate = self;
    ipc.sourceType = UIImagePickerControllerSourceTypeCamera; 
    [self presentModalViewController:ipc animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    img.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [[picker parentViewController]dismissModalViewControllerAnimated:YES];
    [picker release];
}
but i dont know why doesnt save anything !
I suspect your image is released before you save it:
img.image = [info objectForKey:UIImagePickerControllerOriginalImage];
The line above returns an autoreleased object. I suggest you retain the image as shown below and then release it when you have saved the image.
img.image = [[info objectForKey:UIImagePickerControllerOriginalImage] retain];
Call [self savePhoto] in -imagePickerController:didFinishPickingMediaWithInfo: after retrieving the image.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论