[英]popToRootViewController when application enters background
In the didFinishLaunchingWithOptions
of my application , the code is 在我的应用程序的
didFinishLaunchingWithOptions
中,代码为
_homeViewController = [[HomeViewController alloc]init];
UINavigationController* _navigationController = [[UINavigationController alloc] initWithRootViewController:_homeViewController];
[self.window setRootViewController:_navigationController];
[_navigationController setNavigationBarHidden:YES];
[self.window makeKeyAndVisible];
and in the HomeViewController
, I am having two buttons, If the button is pressed , I am presenting the ViewController. 在
HomeViewController
,我有两个按钮,如果按下了按钮,则会显示ViewController。 If button1 is pressed , the code is 如果按下button1,则代码为
if (_detailsViewController == nil)
_detailsViewController = [[DetailsViewController alloc]init];
[self.navigationController presentModalViewController:_detailsViewController animated:YES];
Now when I am in the detailsViewController and I pressing the iPhone Home button, in the same class I am using the UIApplicationDidEnterBackgroundNotification
and calling a method to execute the following line 现在,当我进入detailsViewController并按下iPhone Home按钮时,在同一类中,我使用
UIApplicationDidEnterBackgroundNotification
并调用方法来执行以下行
[self.navigationController popToRootViewControllerAnimated:YES];
So I thought when I open the application again, I can see the HomeViewController, but it doesn't work. 所以我想当我再次打开应用程序时,我可以看到HomeViewController,但是它不起作用。 Please help me !!
请帮我 !!
当您进入背景时,保存一条状态信息,当您重新进入前景时,检查该信息,如果设置了标志,则在其中弹出而没有动画。
看来我无法弹出到根视图的原因是,我在两者之间显示了ViewController,如果ViewController随导航控制器一起提供,即,如果ViewController被推为导航控制器,那么我可以弹出到根视图控制器
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.