Iphone UiTabBarController在popToRootViewController上崩溃

Iphone UiTabBarController在popToRootViewController上崩溃,iphone,ios,uitabbarcontroller,uitabbar,uitabbaritem,Iphone,Ios,Uitabbarcontroller,Uitabbar,Uitabbaritem,我的应用程序在选择选项卡时崩溃。下面是崩溃的代码 - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController { if ([viewController isKindOfClass:[UINavigationController class]]) { [(UINavigationController*)v

我的应用程序在选择选项卡时崩溃。下面是崩溃的代码

- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
if ([viewController isKindOfClass:[UINavigationController class]]) {
    [(UINavigationController*)viewController popToRootViewControllerAnimated:NO];
}


}
这就是问题所在的代码。显然,当我启动PoptRoot控制器时,会向解除分配的对象发送一条消息

DealElementDisplayController *dealElementDisplayController = [[DealElementDisplayController alloc] initWithStores:storeIds :YES];
            dealElementDisplayController.title = [NSString stringWithFormat:@"%@ Products", store.companyName];
            [self.navigationController pushViewController:dealElementDisplayController animated:YES];
这是个例外

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0xe0000008
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libobjc.A.dylib                 0x3648af78 objc_msgSend + 16
1   UIKit                           0x320e809c -[UITableView(UITableViewInternal)             _createPreparedCellForGlobalRow:withIndexPath:] + 540
    2   UIKit                           0x320e717a -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:] + 1070
3   UIKit                           0x320e6904 -[UITableView layoutSubviews] + 200
4   UIKit                           0x3208b0d8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 176
5   CoreFoundation                  0x34fc81f4 -[NSObject performSelector:withObject:] + 36
6   QuartzCore                      0x36b53a9e -[CALayer layoutSublayers] + 210
7   QuartzCore                      0x36b536b6 CA::Layer::layout_if_needed(CA::Transaction*) + 210
8   QuartzCore                      0x36b5783c CA::Context::commit_transaction(CA::Transaction*) + 220
9   QuartzCore                      0x36b57578 CA::Transaction::commit() + 308
10  QuartzCore                      0x36b7f90a CA::Transaction::flush() + 38
11  QuartzCore                      0x36b7f8dc +[CATransaction flush] + 28
12  UIKit                           0x32096152 _afterCACommitHandler + 46
13  CoreFoundation                  0x3503db14 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12
14  CoreFoundation                  0x3503bd50 __CFRunLoopDoObservers + 252
15  CoreFoundation                  0x3503c0aa __CFRunLoopRun + 754
16  CoreFoundation                  0x34fbf49e CFRunLoopRunSpecific + 294
17  CoreFoundation                  0x34fbf366 CFRunLoopRunInMode + 98
18  GraphicsServices                0x362bb432 GSEventRunModal + 130
19  UIKit                           0x320b5e76 UIApplicationMain + 
这是来自僵尸配置文件的堆栈跟踪。我正在使用ARC

   0 CoreFoundation ___forwarding___
   1 CoreFoundation _CF_forwarding_prep_0
   2 UIKit -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:withIndexPath:]
   3 UIKit -[UITableView(UITableViewInternal) _createPreparedCellForGlobalRow:]
   4 UIKit -[UITableView(_UITableViewPrivate) _updateVisibleCellsNow:]
   5 UIKit -[UITableView layoutSubviews]
   6 UIKit -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
   7 CoreFoundation -[NSObject performSelector:withObject:]
   8 QuartzCore -[CALayer layoutSublayers]
   9 QuartzCore CA::Layer::layout_if_needed(CA::Transaction*)
  10 QuartzCore CA::Context::commit_transaction(CA::Transaction*)
  11 QuartzCore CA::Transaction::commit()
  12 QuartzCore +[CATransaction flush]
  13 UIKit _afterCACommitHandler
  14 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
  15 CoreFoundation __CFRunLoopDoObservers
  16 CoreFoundation __CFRunLoopRun
  17 CoreFoundation CFRunLoopRunSpecific
  18 CoreFoundation CFRunLoopRunInMode
  19 GraphicsServices GSEventRunModal
  20 GraphicsServices GSEventRun
  21 UIKit UIApplicationMain

应用程序中出现异常的原因不是由于以下代码出现问题

   - (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
      {
        if ([viewController isKindOfClass:[UINavigationController class]]) {
        [(UINavigationController*)viewController popToRootViewControllerAnimated:NO];
      }
    }

我认为当您点击选项卡栏时,导航控制器弹出
DealElementDisplayController
,并且
DealElementDisplayController
中的一个未分配/释放的变量再次被释放。这可能是你撞车的原因。在
DealElementDisplayController
中签入您的
-(void)dealloc
代码,以确保您已经完成了所有工作。使用仪器中的
zombie
检查异常<代码>僵尸非常适合检测与内存管理相关的异常。

这是因为导航控制器已在根控制器上时调用popToRootViewController

您要导航到的视图是否为UITableViewController?您是否尝试过在-(UITableViewCell*)tableView:(UITableView*)tableView CellForRowatineXpath:(NSIndexPath*)indexPath方法中中断以查看它是否正在渲染?它从未实现。它使其显示为ViewWill,然后抛出异常。视图中没有任何内容会触发异常。我使用的是ARC。我没有在DealElementDisplayControllerI中实现dealloc方法我添加了僵尸配置文件跟踪