2012-12-04 4 views
1

버튼이있는보기에서 iOS 앱을 작성하고 있습니다. 이 단추를 클릭하면 카메라 나 갤러리에서 이미지를 선택할 수있는 옵션이있는 작업 시트가 표시됩니다. 이미지가 선택되면 수동으로 segue를 호출하여 다른보기로 전달해야합니다. 이미지 선택기가 나타나고 세그먼트 코드 준비가 실행되지만 세그먼트가 표시되지 않습니다. 이 오류는 없습니다 내가 코드를 다음 등 모든 식별자를 체크 한 : 당신이 UINavigationController 내부없이 스타일 push와 SEGUE을 실행하는 것처럼Image Picker 이후에 Segue가 표시되지 않습니다.

-(IBAction)showButtonClicked:(id)sender { 
    UIActionSheet *photoActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from Library", nil]; 
    photoActionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent; 
    [photoActionSheet showInView:self.tabBarController.tabBar]; 
} 

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { 

    switch (buttonIndex) { 
    case 0: 
      { 
      [self dismissModalViewControllerAnimated:YES]; 
      UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
      picker.delegate = self; 
      picker.sourceType = UIImagePickerControllerSourceTypeCamera; 
      [self presentModalViewController:picker animated:YES]; 
      break; 
      } 
     case 1: 
      { 
      [self dismissModalViewControllerAnimated:YES]; 
      UIImagePickerController *picker = [[UIImagePickerController alloc] init]; 
      picker.delegate = self; 
      picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; 
      [self presentModalViewController:picker animated:YES]; 
      break; 
      } 
    default: 
      break; 

    } 

} 



- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 

    if ([segue.identifier isEqualToString:@"goToPhotoDetails"]){ 
     FostoPhotoDetailsViewController *photoDetails = (FostoPhotoDetailsViewController *)segue.destinationViewController; 
     photoDetails.imageView.image = self.buttonImage1; 
    } 
} 



- (void) imagePickerController:(UIImagePickerController *)picker 
     didFinishPickingImage:(UIImage *)image 
        editingInfo:(NSDictionary *)editingInfo 
{ 

    self.buttonImage1 = image; 
    //FostoPhotoDetailsViewController *photoDetails = [[FostoPhotoDetailsViewController alloc] init]; 
    //photoDetails.imageView.image = image; 
    [self dismissModalViewControllerAnimated:NO]; 
    NSLog(@"Test"); 
    [self performSegueWithIdentifier:@"goToPhotoDetails" sender:self]; 
} 
+0

segue는 어떻게 구성되어 있습니까? –

답변

2

는 소리.

당신이 호출 할 때 performSegueWithIdentifier:sender: 먼저 제대로 prepareForSegue:sender: 다음은 현재 탐색 컨트롤러를 검색하고

[self.navigationController pushViewController:destinationController animated:YES]; 

같은 일을 대상 컨트롤러를 밀어하려고 호출하지만이 UINavigationController 내부의 속성이 아닙니다 때문에 navigationController이 설정되어 을 nil으로 변경하면 위의 호출이 자동으로 실패합니다.

는 이외로 SEGUE의 표시 스타일을 변경하십시오 push (예를 modal) 또는 당신이 UINavigationController에서 컨트롤러 포함.

+0

고마워요! 그것이 문제였습니다. 이제 작동 중입니다. 두 번째보기로 전달하려는 이미지가 아직 표시되지 않지만 – apr

+1

해당 특정 문제에 대한 다른 질문을 열면 기꺼이 도와 드리겠습니다. –

관련 문제