2012-06-09 2 views
1

내보기의 세트 업입니다. iPad에서 필요하기 때문에 "재설정"버튼을 클릭하여 호출되는 UIPopoverController을 사용해야합니다. 그러나UIPopoverController와 여기 UIImagePickerController를 충돌

-(IBAction) btnReset:(id)sender { 
    [self chooseImage]; 
} 

-(void) chooseImage { 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) { 
     imagepicker = [[UIImagePickerController alloc] init]; 
     imagepicker.allowsEditing = NO; 
     imagepicker.delegate = self; 
     imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
     imagepicker.navigationBar.opaque = true; 


     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { 
      popoverController = [[UIPopoverController alloc] initWithContentViewController:imagepicker]; 

      [popoverController presentPopoverFromBarButtonItem:reset permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; 

     } else { 
      [self presentModalViewController:imagepicker animated:YES]; 
     } 
    } 
} 

오류가있는 뷰 충돌이 호출 할 때 : 내가 잘못 뭐하는 거지

'NSInvalidArgumentException', reason: '-[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:]: Popovers cannot be presented from a view which does not have a window.'

여기 내 코드는? 미리 감사드립니다.

+0

popover에서 표시 할 재설정 변수는 무엇입니까? –

+0

Reset은 버튼의 이름입니다 – DGund

답변

0

보기 계층 구조에없는 항목에 대한 팝업을 만드는 중입니다. 이 메서드가 버튼에 의해 호출되면 메서드 헤더를 - (void) chooseImage : (id) 보낸 사람으로 변경하고 도구 모음에있는 UIBarButton에서 팝업을 표시합니다.

또한 ARC를 사용하는 경우 (사용자의 것처럼 보임) UIPopover를 유지해야합니다. 그렇지 않으면 여전히 필요할 때 해제됩니다. this stack overflow post을 참조하십시오. 당신은 이미 이것을하고 있을지 모르지만 당신이 popoverController를 어떻게 지정했는지를 볼 수없는 것처럼 그것을 키울 것이라고 생각했습니다.

+0

UIBarButtonItem IBAction은 chooseImage 메서드를 호출하기 때문에 괜찮습니다. 내가 다른 게시물의 관점에서해야 코드를 잘 모르겠습니다. 헤더 파일에 popOver를 만들고 속성을 합성했습니다. – DGund

+0

이 게시물을 보셨나요? http://stackoverflow.com/questions/3377001/popovers-cannot-be-presented-from-a-view-which-does-not-have-a-window –

+0

귀하의 링크에서 허용되는 답변 아래의 질문은 최고의 작품 . 완벽하지는 않지만 제대로 작동하게 만들 것입니다. – DGund

관련 문제