2013-02-26 2 views
1

UIModalPresentationFormSheet보기를 닫은 후에 상위보기를 업데이트하는 방법. 기본보기를 사용하면 부모보기를 다시로드 할 수 있습니다. UIModalPresentationFormSheet에만 발급하십시오. 도와주세요. 나는 단지 UIModalPresentationFormSheet에 부모 tableview.Issue를 새로 고칠 수 있습니다부모보기를 다시로드하는 방법

navigationController.modalPresentationStyle = UIModalPresentationFullScreen; 

를 사용하지만 팝업보기를 UIModalPresentationFormSheet를 사용해야하는 경우 감사

navigationController.modalPresentationStyle = UIModalPresentationFormSheet; 

. 도와주세요. 감사합니다

+0

왜 부모보기를 다시로드 하시겠습니까? –

+0

"UIModalPresentationFormSheet"보기에서 일부 데이터를 편집합니다. 부모보기에서 변경 사항을 표시하려고합니다. – Suppry

+2

당신은 (KVO, NSNotificationCenter, 대의원, 참조를 통과하고 많은 방법으로) 변경을 알리기 위해 다른 사람이 필요합니다. –

답변

3

IMO 쉬운 방법 : 생성 (또는 SEGUE 수행) FormController에을 때

//FormController.h 

@protocol FormDelegate; 

@interface FormController : UIViewController 
... 
@property (nonatomic, assign) id <FormDelegate> delegate; 
... 
@end 

@protocol FormDelegate 
-(void)didDismissForm; 
@end 

//MainViewController.h 

#import "FormController.h"  
@interface MainViewController : UIViewController <FormDelegate> 
... 

대리자를 설정합니다.
위임 메서드를 닫을 때 위임 메서드를 호출하십시오. MainViewController에서 대리자 메서드를 구현하십시오.

-(void)didDismissForm { 
    [self.tableView reloadData]; 
} 
+0

에서 내 대답보기 navigationController.modalPresentationStyle = UIModalPresentationFullScreen; 상위 테이블 뷰를 새로 고칠 수 있습니다. UIModalPresentationFormSheet에서만 발생하지만 팝업보기에는 UIModalPresentationFormSheet를 사용해야합니다. 도와주세요. 감사합니다 – Suppry

+0

정확하게 똑같은 방식으로 작동합니다. – Mundi

0

당신은 PresentModalView의 parentView을 위임해야하며 PresentModalView의 viewWillDisappear에 방법을 Referesh는 호출해야합니다.

그렇지 않으면 알림을 푸시하고 parentView에서 관찰 할 수 있습니다.

- (void) refreshMyParentViewController{ 
    NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; 
    [center postNotificationName:@"RefreshNeeded" object:self userInfo:refreshData]; 
} 

// In ParentViewController - AddObserver를 사용하여 데이터를 검색합니다. // 호출 할 메서드.

[[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(delegateMethod:) 
               name:@"RefreshNeeded" object:nil]; 

- (void)delegateMethod:(NSNotification *)notification { 
     NSLog(@"%@", notification.userInfo); 
     NSLog(@"%@", [notification.userInfo objectForKey:@"RefreshObject"]);  
} 



    [[NSNotificationCenter defaultCenter] addObserver:self 
               selector:@selector(delegateMethod:) 
                name:@"RefreshNeeded" object:nil]; 

    - (void)delegateMethod:(NSNotification *)notification { 
      NSLog(@"%@", notification.userInfo); 
      NSLog(@"%@", [notification.userInfo objectForKey:@"RefreshObject"]);  
    } 
관련 문제