0
需要幫助解僱模態呈現視圖控制器,並從彈出的UINavigationController視圖控制器
的AppDelegate
- (void)applicationWillEnterForeground:(UIApplication *)application {
NSLog(@"applicationWillEnterForeground");
[[NSNotificationCenter defaultCenter]postNotificationName:@"applicationWillEnterForeground" object:nil];
}
V1
-(IBAction)uw:(UIStoryboardSegue*)segue{
NSLog(@"Back on V1");
}
V2
-(void)awakeFromNib {
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(goBackToV1) name:@"applicationWillEnterForeground" object:nil];
}
-(void)goBackToV1 {
NSLog(@"goBackToV1");
[self performSegueWithIdentifier:@"uwid" sender:nil];
}
V3 本模態從V2
並且沒有代碼。
運行應用程序後,我點擊主頁按鈕,再次打開應用程序,這個觸發通知,並收到V2
。
什麼V2
是應該做的:
- 辭退
V3
。如果V3
沒有ViewController
子類,那麼它被解僱否則它不是。 V2
本身必須從UINavigationController
中彈出,但如果V3
沒有被解僱但是給出日誌goBackToV1
,則它不會彈出。
如果V3
我這樣做NSLog(@"%@", [self presentingViewController]);
我得到<UINavigationController: 0x13582d800>
我的問題:
- 爲什麼
V3
當沒有視圖控制器子類分配給它被擱置了。 - 爲什麼
V3
在ViewController子類被分配給它時不會被解僱。 - 爲什麼
performSegueWithIdentifier
在V2
沒有彈出到V1
儘管代碼被執行,但它的簡單被忽略。
感謝解決我的問題,請你也可以根據我問的問題解釋一下嗎? –
可能是因爲您沒有關閉V3,因此V2仍然需要位於視圖層次結構中,因爲它是V3的演示視圖控制器 – ogres
但是,爲什麼在自定義視圖控制器類未分配到故事板時V3會自動被解除? –