2013-07-17 24 views
2

有沒有一種方法可以區分我的視圖控制器viewDidAppear方法在用戶切換選項卡後還是在導航控制器彈出後調用?viewDidAppear tab switch vs nav pop

感謝

+0

澄清導航控制器彈出的含義。你的意思是這個視圖沒有被推入導航堆棧,而是作爲一個模式呈現? – HepaKKes

回答

1

viewWillAppear中和viewDidAppear都得到所謂的導航流行音樂和TabBar開關,你可以(如果你還沒有這麼做過實現它)通過使用標籤欄的委託方法區別開來

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item 

可能會在這裏設置一個布爾什麼的。

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item 
{ 
    YOUR_VIEW_STATUS = YES; 
} 

-(void)viewWillAppear:(BOOL)animated 
{ 
    [self viewDidAppear:YES]; 

    if(!YOUR_VIEW_STATUS) 
    { 
    //navigation pop or push 
    } 

    else 
    { 
    //tab bar switch 
    } 
}