2012-03-05 5 views
0

테이블 셀을 선택하면 사진 라이브러리에서 이미지를 선택하거나 새 이미지를 가져와야합니다.iOS - UITableView를 통해 UIImagePicker를 표시하려면 어떻게해야하나요?

화면 구조는 다음과 같습니다 셀을 터치하면

UITabBar -> UINavigationController -> ParentController -> MyController 

MyController이를 달성하기 위해 코드는

- (void)showPhotoMenu 
{ 
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) { 

     UIActionSheet *actionSheet = [[UIActionSheet alloc] 
            initWithTitle:nil 
            delegate:self 
            cancelButtonTitle:@"Cancel" 
            destructiveButtonTitle:nil 
            otherButtonTitles:@"Take Photo", @"Choose From Library", nil]; 

     [actionSheet showInView:self.view]; 
    } else { 
     [self choosePhotoFromLibrary]; 
    } 
} 

, 나는 도서관에서 선택하거나 사진만을 취할 수있는 옵션을 얻을 그 후에 일어나는 것 같다. 로그 출력은

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:]. 

을 보여줍니다하지만 난 ImagePicker 화면 (사진 라이브러리 또는 카메라)이 표시되지 않습니다 그 이유는 확실하지 않다.

내가 수집 한 것으로부터, 탭 바를 포함하고 있기 때문에 취소 버튼에 액세스 할 수 없다는 경고가 나옵니까?

내가 어디에서 잘못 될지 조언 해 줄 사람이 있습니까?

+0

Firs off,'UIActionSheet'에 대한 해결책은 오류이며'UIImagePickerController'를 표시하는 코드는 어디에 있습니까? – rckoenes

+0

당신이 imagePickerController를 어떻게 보여주고 있는지 보여줍니다 .. – vishy

답변

1

확실히 말할 코드 충분하지하지만

액션 시트는 대리인으로 코드를 사용하고 반환 고정 대리자 메서드

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 
    if (buttonIndex == actionSheet.firstOtherButtonIndex + 0) { 
    //code to take photo 
    } else if (buttonIndex == actionSheet.firstOtherButtonIndex + 1) { 
    //code to take access media 
    } 
} 

다른 경고 메시지에 당신에게 제어 - 행동 강령에 모든 옵션이 보이지 않습니까?

[actionSheet showInView:self.view]; 

당신이 탐색 모음 또는 탭 표시 줄이있는 경우에 따라 몇 가지 더 많은 옵션이 있습니다, 당신보다 더 많은 액션 시트 선택과 아이폰 프로그램을 가지고 있고 나는 오류가 발생하지 않습니다.

+0

오 Derp derp derp - 델리게이트 메서드를 추가하는 것을 완전히 잊어 버렸습니다 : /이게 잘 작동합니다 - 도와 줘서 고마워요 – bodacious

+0

내 작업 시트에있는 모든 동작을 봅니다. 취소, 절반 만 활성화됩니다. 아래쪽 절반을 탭하면 탭 바가 그것을 감싸서 응답하지 않습니다. 내가 위쪽 절반을 탭하면 잘 작동합니다. – bodacious

관련 문제