2015-01-11 2 views
0

모달을 닫은 후에 UILabels를 업데이트하려고 할 때 문제가 있습니다. 기본적으로 가지고 있습니다 : 일부 UILabels 및 UIButtons와 함께 ViewController 내가 버튼을 터치하면 텍스트 필드가있는 모달이 열리 며,이 텍스트 필드에 텍스트를 입력하여 내가 한 CacheHandler의 인스턴스에 저장합니다. 그런 다음 모달을 버튼으로 닫고 UILabel에 입력 한 텍스트를보고 싶습니다. 텍스트가 캐시에 저장되었습니다. 확인했습니다. 사용자 지정 세그먼트 (Segue)에서 레이블을 호출 할 때 레이블을 업데이트하는 메서드가 있습니다. 레이블 값은 null입니다. 내가 어디에서 잘못하고 있니?모달 뷰를 닫을 때 UILabels 업데이트

사용자 정의 SEGUE :

#import "DismissModalSegue.h" 
#import "CreateSqeedViewController.h" 

@implementation DismissModalSegue 

- (void)perform { 
    UIViewController *sourceViewController = self.sourceViewController; 
    CreateSqeedViewController *destViewController = self.destinationViewController; 
    [sourceViewController.presentingViewController dismissViewControllerAnimated:YES completion:^{ 
     [destViewController updateLabels]; 
    }]; 
} 

@end 

updateLabels 방법 : 레이블을 초기화

- (void)updateLabels { 
    NSLog(@"Updating labels: %@", [[[CacheHandler instance] createSqeed] place]); 
/* displays what I want to display in my label */ 
    NSLog(@"%@", whatLabel.text); 
/* displays null */ 
    whereLabel.text = [[[CacheHandler instance] createSqeed] place]; 
    whatLabel.text = [[[CacheHandler instance] createSqeed] sqeedDescription]; 
    NSString *peopleLabel = [NSString stringWithFormat:@"%@/%@", [[[CacheHandler instance] createSqeed] peopleMin], [[[CacheHandler instance] createSqeed] peopleMax]]; 
    whoLabel.text = peopleLabel; 
    whereLabel.text = [[[[CacheHandler instance] createSqeed] dateStart] description]; 
} 
+0

VC에서 메서드를 호출하는 unwind segue를 사용하지 않는 이유는 무엇입니까? 그리고 주문 segue에있는 아무 필요도. – Andy

답변

0

? IBOutlet과 연결되어 있습니까? 초기화되지 않을 때 다시 호출 할 수 있습니다.

+0

이들은 .h의 IBOutlet 속성이고 .m의 합성어입니다. viewDidLoad 메서드를 체크하고 완벽하게 초기화되었으므로 기본값을 갖습니다. – stowka

+0

updateLabels 메서드가 올바르게 호출 되었습니까? NSNotificationCenter를 사용하여 메서드를 호출하라는 알림을 보낼 수 있습니다. – weso

+0

여기를보세요. [link] http://stackoverflow.com/questions/27874673/how-to-send-string-value-from-secondview-to-mainview-with-use-popover-segue [/ link] – weso

관련 문제