0

기본적으로 prepareForSegue 메서드를 사용하여 스토리 보드에서 다른보기로 전환하고 내보기를 내비게이션 컨트롤러에 포함시켜 내비게이션 막대를 표시해야합니다. 방법 :prepareForSegue를 사용하여 메서드 값 설정

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 
    if([segue.identifier isEqualToString:@"exploreAddSelected"]){ 

     UINavigationController *navController = (UINavigationController *)segue.destinationViewController; 
     AddTableViewController *controller = (AddTableViewController *)navController.topViewController; 
     controller.tagName = tagName; 
    } 
} 

내 문제는 내가 prepareForSegue 방법을 사용하는 경우 다음과 같습니다과 pushViewController를 사용할 때 당신이 할 수있는, 실제 뷰 컨트롤러에 몇 가지 방법 값을 설정 할 수 있어야입니다 :

DetailViewController *detailViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"DetailViewController"]; 
detailViewController.tagName = tagName; 
[detailViewController setCurrentHashtag:nil]; 
[navigationController pushViewController:self.detailViewController animated:YES]; 

"setCu를 설정할 수 있어야합니다. rrentHashtag "메서드를 사용하여 뷰 컨트롤러에서 segue"exploreAddSelected "로 이동합니다. 어떻게하면 좋을까요?

+2

나는 이해할 수 없다. 당신이'controller.tagName = tagName; '에서 그렇게 해왔 던가? 왜'controller setCurrentHashtag : nil];'예를 들어? –

+0

실제로 작동하지 않지만 controller.taganame은 완전히 다른 것입니다. –

답변

0

이 답변은 실제로 매우 분명하지만 답변을 직접 깨닫는 질문이 필요합니다.

님의 간단하게 설정할 수 있습니다 currentHashtag 뷰 컨트롤러에 새로 선언 된 인스턴스

controller.currentHashtag = nil; 

. 그런 다음 실제 뷰 컨트롤러 세트 :

[self setCurrentHashtag:currentHashtag]; 
+0

'controller.currentHashtag = nil'은'[controller setCurrentHashtag : nil]'과 완전히 똑같습니다. 후자의 구문을 시도했을 때 어떤 일이 일어 났습니까? –

0

그냥 방법에 currentHashtag를 추가합니다.

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ 
    if([segue.identifier isEqualToString:@"exploreAddSelected"]){ 

    UINavigationController *navController = (UINavigationController *)segue.destinationViewController; 
    AddTableViewController *controller = (AddTableViewController *)navController.topViewController; 
    controller.tagName = tagName; 
    [controller setCurrentHashTag:nil]; //add this line 
    } 
} 

여기에서 무엇을하고 있는지 잘 모르겠습니다. segue가 뷰 컨트롤러를 직접 가리키면 (그리고 다른 네비게이션 컨트롤러를 통해서도), topviewcontroller에 매핑 할 필요는 없지만 destinationcontroller를 직접 사용하십시오.

관련 문제