PushViewController Crash in IOS7

那年仲夏 提交于 2019-12-08 13:43:12

问题


I am facing strange issue in IOS7 when I try to run my old app in xcode5 with IOS6 every thing working fine,but with IOS7 when I am trying to Push Nextview it Crash.Here is code where my app Crash.

 FamilyBioViewController *detailView=[[FamilyBioViewController alloc] initWithNibName:@"FamilyBioView" bundle:[NSBundle mainBundle]];
 [self.navigationController pushViewController:detailView animated:YES];
 [detailView release];

When crash happened it did not show any error in console.The below screenshot show the crash result

Interesting thing is when I present my view with presentViewController instead of pushViewController then it is working fine in IOS 7 .
FamilyBioViewController *detailView=[[FamilyBioViewController alloc] initWithNibName:@"FamilyBioView" bundle:[NSBundle mainBundle]];
 [self presentViewController:detailView animated:YES completion:nil];
 [detailView release];

So the Question is why pushViewController Causing problem in IOS7 ? Any help will be appreciated.Thanks in advance.

Edit: For more Detail see my app Flow

and here is my AppDelegate Code
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
  {
 if(tabBarController.selectedIndex==1 || tabBarController.selectedIndex==3)
 {
    [(UINavigationController *)[tabBarController selectedViewController] popToRootViewControllerAnimated:NO];
}
  }

- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
 {
   return YES;
 }

回答1:


FamilyBioViewController *detailView = [[[FamilyBioViewController alloc] initWithNibName:@"FamilyBioView" bundle:[NSBundle mainBundle]] autorelease];
[self.navigationController pushViewController:detailView animated:YES];

---- EDIT ---- my example above it's not the solution!

don't forget to declare your first viewController for a navigationController

in iOS6 it wasn't a big problem. In iOS7 it is!

have a look to

[[UINavigationController alloc] initWithRootViewController: (UIViewController *)controller]

You can push only if you have a root!




回答2:


The view controller in the view controller array must be unique



来源:https://stackoverflow.com/questions/20005721/pushviewcontroller-crash-in-ios7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!