2013-01-21 2 views
0

내 현재 코드는 다음과 같습니다저장 사진

- (IBAction)cameraButtonAction:(id)sender { 
    UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
    picker.allowsEditing = NO; 
    picker.sourceType = (sender == cameraButton) ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypeSavedPhotosAlbum; 
    [self presentModalViewController:picker animated:YES]; 
} 

이 기본 카메라를 가져오고있다,하지만 난 use을 선택할 때 사진을 저장하지 않습니다. 나는 시도했다 :

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo { 
    UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil); 
    [self dismissModalViewControllerAnimated:YES]; 
} 

내가 살펴본 모든 튜토리얼, 그들은 UIImageView를 사용하여 사용자 정의 카메라 앱을하지만 내가, 내가 다시 응용 프로그램에서 이미지를 표시하지 않으 수행 할 작업을하지 않고 기본 카메라 기능을 유지하고 싶습니다.

답변

1

코드가 정확합니다. 하지만 당신은 여기에 한 줄을 누락 대리인

를 설정하지 않은 :

picker.delegate = self; 

당신은 당신의 cameraButtonAction 방법이를 추가해야합니다.

- (IBAction)cameraButtonAction:(id)sender 
{ 
    UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
    picker.delegate = self; 
    picker.allowsEditing = NO; 
    picker.sourceType = (sender == cameraButton) ? UIImagePickerControllerSourceTypeCamera : UIImagePickerControllerSourceTypeSavedPhotosAlbum; 
    [self presentModalViewController:picker animated:YES]; 
} 
+0

내 책상이 내 얼굴에 각인되었습니다! 감사합니다 –

+0

@Onkyo : 즐거움과 함께 :) 당신의 의견을 주셔서 감사합니다 친구 :) 행운을 빌어 요 –