简体   繁体   English

self.navigationcontroller popviewcontrolleranimated是,终止我的应用

[英]self.navigationcontroller popviewcontrolleranimated yes, terminates my app

I have navigation application. 我有导航应用程序。 I have created a UINavigationController in application didFinishLaunchingWithOptions of appdelegate. 我在appdelegate的应用程序didFinishLaunchingWithOptions中创建了一个UINavigationController。 self.initialviewcontroller = [[InitialViewController alloc] initWithNibName:@"InitialViewController" bundle:nil]; self.initialviewcontroller = [[[InitialViewController alloc] initWithNibName:@“ InitialViewController” bundle:nil]; UINavigationController *myNavController = [[UINavigationController alloc] initWithRootViewController:self.initialviewcontroller]; UINavigationController * myNavController = [[UINavigationController alloc] initWithRootViewController:self.initialviewcontroller];

self.window.rootViewController = myNavController; self.window.rootViewController = myNavController; [self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];

In the InitialViewController i have button which will navigate to SecondViewController. 在InitialViewController中,我有一个将导航到SecondViewController的按钮。 So, in the IBAction of button i push the SecondViewController as follows, 因此,在按钮的IBAction中,我按如下所示按下SecondViewController,

if(self.secondView != nil)
  self.secondView = nil;
self.secondView = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
self.navigationController pushViewController:self.secondView animated:YES];

Situation : The navigation is working fine, i am bale to navigate between InitialViewController to SecondViewController. 情况:导航工作正常,我打包在InitialViewController到SecondViewController之间导航。 When i am in SecondViewController and press home button of device, the application is entered into background and when i reopen the app it opens the app from where i closes(ie SecondViewController). 当我在SecondViewController中并按设备的主页按钮时,该应用程序将进入后台,当我重新打开该应用程序时,它将从我关闭的位置(即SecondViewController)打开该应用程序。 Now if i press the back button to go to InitialViewController, the app is crashing. 现在,如果我按后退按钮转到InitialViewController,则应用程序崩溃。

It's working fine in the ios simulator,but crashes occurs on devices. 在ios模拟器中可以正常工作,但是设备会崩溃。

I didn't understand what the mistake i have done. 我不明白我犯了什么错误。 Please let me know any idea. 请让我知道任何想法。 Thanks in advance.... 提前致谢....

Try dissmissing your view controller using 尝试使用解雇视图控制器

[self dismissModalViewControllerAnimated:YES]; [self dismissModalViewControllerAnimated:YES];

It works for me. 这个对我有用。 Even for iOS 6. 即使是iOS 6。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 [self.navigationController popViewControllerAnimated:YES]; 在委托回调中不起作用 - [ self.navigationController popViewControllerAnimated:YES ]; doesn't work in delegate callback self.navigationController?来自UIAlertController的.popViewControllerAnimated - self.navigationController?.popViewControllerAnimated from UIAlertController 在调用popToRootViewControllerAnimated:YES后在self.navigationController中取消分配或删除ViewControllers - dealloc or remove ViewControllers in self.navigationController after popToRootViewControllerAnimated:YES is called [self.navigationController pushViewController:ngView animated:YES]; 不工作 - [self.navigationController pushViewController:ngView animated:YES]; not working 在[self.navigationController popToRootViewControllerAnimated:YES]期间分配变量; - Assigning a variable during [self.navigationController popToRootViewControllerAnimated:YES]; iOS-[self.navigationController setToolbarHidden:YES动画:NO]崩溃 - iOS - Crash on [self.navigationController setToolbarHidden:YES animated:NO] Deallocated error self.navigationController ==无 - self.navigationController == nil Self.NavigationController =在表视图中为null? - Self.NavigationController = null in tableview? self.navigationController pushViewController 不工作 - self.navigationController pushViewController not working self.navigationController 始终为零 - self.navigationController is always nil
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM