2010-05-21 5 views
0

하나의 탭이 일련의보기를 통해 이동하기 위해 탐색 컨트롤러를 사용하는 탭 막대 응용 프로그램이 있습니다. 마지막보기에는 UIImagePickerController를 제공하는 사진을 추가하는 버튼이 있습니다. 지금까지는 이미지를 선택하거나 작업을 취소했지만 이전 뷰는로드되지만 탭 막대는 표시되지 않습니다. 초급 뭔가를 놓치고있어 확신 해요,하지만 UIImagePickerController 제대로 해제하는 방법에 대한 제안을 많이 주시면 감사하겠습니다. 코드는 다음과 같습니다.UITabBarController에서 UIImagePickerController 닫기

ImagePickerViewController *aController = [[ImagePickerViewController alloc];    initWithNibName:@"ImagePickerViewController" bundle:[NSBundle mainBundle]]; 
[self presentModalViewController:aController animated:YES]; 
[aController release]; 

//viewDidLoad 
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
imagePickerController = [[UIImagePickerController alloc] init]; 
imagePickerController.delegate = self; 

if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]){ 
     imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera; 
} else { 
     imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
} 

[window addSubview:imagePickerController.view]; 

//ImagePickerViewController imagePickerControllerDidCancel - FinalViewController is the last view in the stack controlled by a navigation controller which contains the button to present the UIImagePickerController 

[picker dismissModalViewControllerAnimated:YES]; 
FinalViewController *aController = [[FinalViewController alloc initWithNibName:@"FinalViewController" bundle:[NSBundle mainBundle]]; 
[picker presentModalViewController:aController animated:YES]; 
[aController release]; 

답변

3

선택기보기를 창의 하위보기로 추가하지 않아도됩니다.

- (IBAction) snapPicture{ 


      UIImagePickerController *ipc = [[UIImagePickerController alloc] init]; 
      // Set up the source 
      if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){ 
       ipc.sourceType = UIImagePickerControllerSourceTypeCamera; 
       ipc.allowsEditing = NO; 
      } 
      else { 
        ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
       } 

      ipc.delegate = self; 
      [self presentModalViewController:ipc animated:YES]; 
      [ipc release]; 


} 

그렇다면, 선택기 위임 방법을 구현한다 : 사용자가 버튼을 누를 때 다음 snapPicture 방법과 유사한 것을 실행한다. 여기 나는 그 중 하나를 제시하여 피커를 해산시키는 방법을 보여줄 것이다.

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)imagePicker 
{ 

    [[imagePicker parentViewController] dismissModalViewControllerAnimated:YES]; 

} 
+0

이 문제는 직접적인 문제는 물론 모달 뷰 컨트롤러를 이해하는 데 큰 도움이되었습니다. 정말 고마워. – Dave

+0

답변이 도움이된다면, 투표를 고려해 볼 수도 있고, 결정적으로 받아 들일 수도 있습니다 ;-) –

관련 문제