2012-07-24 59 views
0

我有一个在iOS 5中运行良好的应用程序,但是当我在iOS 4中尝试时,出现EXC_BAD_ACCESS错误。我有一个是在AppDelegate中添加如下一个标签栏:不能在iOS 4中从一个选项卡移动到另一个选项卡

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease]; 
self.window.backgroundColor = [UIColor whiteColor]; 
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault animated:NO]; 

UITabBarController *tabBarController=[[UITabBarController alloc] init]; 

searchTableViewController = [[SearchTableViewController alloc] initWithStyle:UITableViewStylePlain]; 
UINavigationController *navControllerSearch=[[UINavigationController alloc] initWithRootViewController:searchTableViewController]; 

firstviewcontroller = [[FirstViewController alloc] initWithStyle:UITableViewStyleGrouped] ; 
UINavigationController *navFirstView=[[UINavigationController alloc] initWithRootViewController:firstviewcontroller]; 
[[FirstViewController tableView] setScrollEnabled:NO]; 

secondViewController = [[SecondViewController alloc] initWithStyle:UITableViewStyleGrouped]; 
UINavigationController *navsecondView=[[UINavigationController alloc] initWithRootViewController:secondViewController]; 
[[SecondViewController tableView] setScrollEnabled:NO]; 

[tabBarController setViewControllers:[NSArray arrayWithObjects:navFirstView, navSecondView, navControllerSearch, nil]]; 

[self.window setRootViewController:tabBarController]; 

当我尝试从第一片移动到第二个应用程序崩溃。在iOS 5中,它运行良好。 iOS部署目标属性是iOS 4.0。

如果我运行仪器,寻找僵尸,我能找到一个僵尸具有以下信息:

# Address Category Event Type RefCt Timestamp Size Responsible  Library Responsible Caller 
1 0x5a21880 CALayer Zombie -1 00:10.816.545 0 QuartzCore -[CALayerArray copyWithZone:] 


0 CoreFoundation ___forwarding___ 
1 CoreFoundation _CF_forwarding_prep_0 
2 CoreFoundation CFRetain 
3 CoreFoundation +[__NSArrayI __new::] 
4 QuartzCore -[CALayerArray copyWithZone:] 
5 CoreFoundation -[NSObject(NSObject) copy] 
6 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] 
7 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] 
8 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] 
9 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] 
10 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] 
11 UIKit -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] 
12 UIKit -[UIView(Hierarchy) removeFromSuperview] 
13 UIKit -[UITransitionView _didCompleteTransition:] 
14 UIKit -[UITransitionView transition:fromView:toView:] 
15 UIKit -[UITransitionView transition:toView:] 
16 UIKit -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] 
17 UIKit -[UITabBarController transitionFromViewController:toViewController:] 
18 UIKit -[UITabBarController _setSelectedViewController:] 
19 UIKit -[UITabBarController _tabBarItemClicked:] 

任何想法?

回答

0

您可能想要检查第二个ViewController中的代码,可能是在加载时崩溃了,看起来像在转换完成后发生崩溃。 尝试调试你viewWillApear或viewDidLoad。 其他标签是否也崩溃?

+0

是的,其他Tabs也崩溃了。 viewWillAppear和viewDidLoad不会执行(在此之前崩溃) – Tony 2012-07-25 11:03:43

相关问题