1

이것은 정확하게 수행하려고 시도한 것입니다.DetailViewController에서 MasterViewController로 데이터를 전송합니다.

wizardviewcontroller.m

- (IBAction)onCountryClick:(id)sender { 
    MJDetailViewController *detailViewController = [[MJDetailViewController alloc] initWithNibName:@"MJDetailViewController" bundle:nil]; 
    [self presentPopupViewController:detailViewController animationType:MJPopupViewAnimationSlideLeftRight]; 
} 

사용자 클릭 국가 버튼 팝업 목록으로 보여줍니다.

사용자가 행을 선택하면 버튼 제목이 변경됩니다.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath  *)indexPath { 

    WizardViewController *mj = [[WizardViewController alloc]  initWithNibName:@"WizardViewController" bundle:nil]; 
    mj.countryselected = [countryNames objectAtIndex:indexPath.row]; 
    [mj.countryButton setTitle:mj.countryselected forState:UIControlStateNormal]; 
    [self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade]; 
} 

DetailViewController

이 기각되고, 내 detailview이지만, countryButtonTitle는 업데이트되지 않습니다. 나는 Wizardview가 상쾌하지 않기 때문에 이것이라는 것을 압니다. 이 경우 올바른 해결 방법을 알고 싶습니다.

희망이 있으면 더 나은 답변을 얻을 수 있습니다.

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath  *)indexPath { 

    NSString *title = [countryNames objectAtIndex:indexPath.row]; 
     if ([self.delegate respondsToSelector:@selector(selectedContry:)]) { 
      [self.delegate selectedContry:title]; 
     } 
    [self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade]; 
} 

같이 MJDetailViewControllerDelegate 추가처럼 MJDetailViewController

@protocol MJDetailViewControllerDelegate; 
@interface MJDetailViewController : UIViewController 
@property (nonatomic,assign) id< MJDetailViewControllerDelegate> delegate; 
@end 


@protocol MJDetailViewControllerDelegate <NSObject> 

- (void)selectedContry:(NSString *)title; 

@end 

에서

+1

코드에서 WizardViewController의 * 새 인스턴스를 만들고 해당 새 인스턴스에 속성을 설정합니다. 기존 * 마스터 뷰 컨트롤러의 속성을 설정해야합니다. –

+0

내 마스터보기 컨트롤러는 WizardViewController입니다. – jack

+0

정확하지 않습니다. ** WizardViewController의 인스턴스입니다. 새 것을 만들면 다른 대상이됩니다. –

답변

2

만들기 프로토콜과 호출

지금에 selectedContry: 메소드를 구현) WizardViewController.hWizardViewController.m 같은 :

- (void)selectedContry:(NSString *)title 
{ 
    [self.countryButton setTitle:title forState:UIControlStateNormal]; 
} 

희망이 있으면 도움이됩니다.

+0

+1 좋은 답변, 일부 수정을 마쳤습니다. 나는 네가 꺼려하지 않을 것을 희망한다. – viral

관련 문제