0
我有一個基於導航的應用程序,其中一個視圖顯示一個工具欄。如果我按Home鍵並重新進入應用程序,工具欄會隱藏自身。我試圖取消隱藏viewDidAppear/viewWillAppear,但他們從不開火。導航工具欄隱藏應用程序重新啓動時
哪裏是取消隱藏工具欄的適當位置?
我有一個基於導航的應用程序,其中一個視圖顯示一個工具欄。如果我按Home鍵並重新進入應用程序,工具欄會隱藏自身。我試圖取消隱藏viewDidAppear/viewWillAppear,但他們從不開火。導航工具欄隱藏應用程序重新啓動時
哪裏是取消隱藏工具欄的適當位置?
當應用程序進入前景時,ViewDidAppear/ViewWillAppear不會被調用。要處理前臺輸入的應用程序,您需要創建一個通知。
在AppDelegate中添加以下代碼applicationWillEnterForeground:
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[NSNotificationCenter defaultCenter] postNotificationName: @"UIApplicationWillEnterForegroundNotification" object: nil];
}
然後在相應的視圖控制器做如下改變
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(handleEnterForeground:)
name: @"UIApplicationWillEnterForegroundNotification"
object: nil];
}
- (void) handleEnterForeground: (NSNotification*) sender
{
//Do whatever you need to do to handle the enter foreground notification
}