아무도이 문제를 해결할 수 있습니까?UIImagePickerController를 사용하고 IOS를 사용하여 IOS를 개발하면 앱이 멈추게됩니다 (크래시가 아님)
마지막 질문에서와 같이, 나는 3 개의 탭 항목과 함께 tabBarController를 사용하고 있습니다. 세 번째 탭에는 카메라 (UIImagePickerController)가있는 uiViewController가 있습니다.
이제 모든 것이 한 가지를 제외하고는 작동합니다. 카메라로 이미지를 촬영하고 "사용"을 누르면 이미지가 저장되었다는 알림이 표시되고 사진 앨범에서 볼 수 있습니다 (앱을 닫고 보았을 때). 그러나이 앱은이 점에 박히지 않습니다. 그리고 나는 더 이상 아무것도 할 수 없다. 화면에서 이미지를 볼 수 있으며 "사용"및 "다시 찍기"버튼을 사용할 수 없습니다. 그냥 그렇게 붙어있어.
내가 여기서 잘못하고있는 것을 볼 수 있습니까?
ps. 모든 예제와 튜토리얼에서 나는 취소의 선택기 릴리스가 있다는 것을 발견했다 ... (또한 내 코드에서). 내 경우 피커 뷰 컨트롤러 (imgPicker) 속성이며 dealloc 메서드에서 언제나처럼 그것을 릴리스, 쓰기 또는 잘못 있습니까? 내가 그 것처럼 살거야, 아니면 여기서 나쁜 기억을하고있는 것일까? (나는 여기서 나쁜 기억 오류를 얻지는 못한다. 그러나 내 실수일지도 모른다. ..)?
viveWillAppear 대리자 메서드에서 UIImagePicker를로드합니다. 당신은 오른쪽에있어,
#pragma mark -
#pragma mark - UIImagePicker delegate methods
//saving the image that was taken
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo: (NSDictionary *)info
{
// Access the uncropped image from info dictionary
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
// Save image
UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
[picker release];
}
//alerting the user if the images was saved or not
- (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo
{
UIAlertView *alert;
// Unable to save the image
if (error)
alert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"Unable to save image to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
else // All is well
alert = [[UIAlertView alloc] initWithTitle:@"Success"
message:@"Image saved to Photo Album."
delegate:self cancelButtonTitle:@"Ok"
otherButtonTitles:nil];
[alert show];
[alert release];
}
//if user is cancelling the camera
-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
[self.tabBarController setSelectedIndex:0];
}
가 대단히 감사합니다 Erez
대답 해 주셔서 감사합니다,하지만 난 여전히 무엇을 이해하지 : 더 코드
위임을 도움이됩니다. didFinishPicking .... 메서드에 동일한 것을 추가하고 동일한 결과를 얻고 있습니다. 그리고 imgPicker에 대한 할당량을 viewDidLoad로 변경 한 다음 하나의 릴리스에 하나의 alloc을 할당합니다 (dealloc에서 release). – Erez
내 prev 코멘트에 신경 쓰지 마라, 당신의 대답은 완벽했다, 고맙다 .-) – Erez
어쨌든 더 많은 코드를 추가했다 :) –