tags:

views:

137

answers:

1

I want to select a image from Photo library or camera and have to save it into my photo album(If its already there i want to put 1 more copy)

-(IBAction) getPhoto:(id) sender {
    UIImagePickerController * picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    if((UIButton *) sender == choosePhotoBtn) {
        picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    } else {
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    }

    [self presentModalViewController:picker animated:YES];

}

-(IBAction) savePhoto:(id) sender
{
    UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCamera
    UIImageWriteToSavedPhotosAlbum(myImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
    printf("Hello world");

}

Here my savePhoto function os not working

A: 
UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCamera

I don't know what it's doing here. In C / C++ the || operator always returns a bool (int), so it's definitely not an UIImage.

If the image picked from the UIImagePickerController is needed, implement the -imagePickerController:didFinishPickingMediaWithInfo: method for the delegate, then read the UIImagePickerControllerEditedImage key of the info.

If a custom image needs to be saved, pass an actual UIImage.

KennyTM
UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCameraThis is not the real code, for understanding only i give like this.. Here i want to giver either library image file or from cam. My purpose is by button click "save" the current image from library or camera have to save back to my photo library folderOn button click savePhoto function is executingPLz help.. My knowledge on Iphone is very less
*"my photo library folder"*: accessible in your app only, or put it in camera roll?
KennyTM