2012-09-12 4 views
6

Tabbar 컨트롤러 (UIViewController)에 포함 된 모든 뷰를 다시로드하고 싶습니다. 검색 한 후 setNeedsDisplay 메서드를 적용했지만 발견 할 수 없습니다. 다른 대안 또한UIViewController를 다시로드하는 방법

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    ..... 
    ..... 

    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
    [self customToolbar]; 
    [self.window addSubview:tabBarController.view]; 
    [self.window makeKeyAndVisible];  
    return YES; 
} 
-(void)customToolbar 
{ 
    //Declared view controllers and their Navigation Controller 
    ..... 

    //Declared tab bar items 
    .....  

    tabBarController = [[GTabBar alloc] initWithTabViewControllers:viewControllersArray tabItems:tabItemsArray initialTab:1]; 
} 
+0

VC를 새로 고침/새로 고침하려면? – Maulik

+0

단추를 눌렀을 때 VC의 리로드를 원할 때 다른 NSObject 클래스의 응용 프로그램 대리인을 호출합니다. –

답변

4

특정 NSNotificationCenter 알림 이름 관찰자로 갱신 될 필요가있는 VC를 추가하는 것이 작업을 수행하는 올바른 방법을 환영합니다. VC가이 메시지를 받으면 [self setNeedsDisplay]을 호출하는 선택기를 호출하면됩니다.

는 NSNotificationCenter에 VC를 추가하려면 뷰 컨트롤러가 해제 될 때
[[NSNotificationCenter defaultCenter] addObserver:self selector: @selector(setNeedsDisplay) name:@"ViewControllerShouldReloadNotification" object:nil]; 

removeObserver:self를 호출하는 것을 잊지 마십시오.

+0

안녕하세요.이 메서드는 어디에 넣을 수 있습니까? 나는 "ViewWillAppear"을 의미합니까? tabbar를 바꿀 때 view cart 웹 서비스를 호출합니다. UIViewController 클래스를 사용하고 있습니다. –

+1

ViewWillAppear는보기가 표시 될 때마다 호출됩니다. 탭 막대 사이를 전환 할 때뿐만 아니라 탐색 스택에서 컨트롤러를 밀거나 팝하거나 모달보기를 표시하거나 해제 할 때도 호출됩니다. 그게 네가 필요로하는 것이면 네, 그렇지 않으면 너는 다른 것을 생각할 필요가있을거야. – Stavash

관련 문제