2014-04-14 142 views
-1

对不起,我已经缩小了错误,因此它不是AFNetworking问题,而是UI问题。尝试关闭iOS中的弹出窗口时出现异常

我有一个集合视图。当我点击集合视图时,会显示一个弹出窗口,我可以选择下载某个内容,然后进度条显示进度。同时,collectionviewcell还会在其自身上显示另一个进度条。然后我关上窗户,再次敲击牢房,做点什么然后关上它。它可能不会在第二次引发异常,并且当我再次打开并关闭popOver时,引发异常。

这里是LLDB的BT跟踪:

* thread #1: tid = 0x1214fc, 0x38592626 libobjc.A.dylib`objc_msgSend + 6, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xb1b8d8b0) 
    frame #0: 0x38592626 libobjc.A.dylib`objc_msgSend + 6 
    frame #1: 0x302f7056 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 90 
    frame #2: 0x302f6ff6 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 30 
    frame #3: 0x302f6fd0 UIKit`-[UIControl sendAction:to:forEvent:] + 44 
    frame #4: 0x302e2736 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 374 
    frame #5: 0x302f6a4e UIKit`-[UIControl touchesEnded:withEvent:] + 590 
    frame #6: 0x302f6720 UIKit`-[UIWindow _sendTouchesForEvent:] + 528 
    frame #7: 0x302f16ea UIKit`-[UIWindow sendEvent:] + 758 
    frame #8: 0x302c68ec UIKit`-[UIApplication sendEvent:] + 196 
    frame #9: 0x302c4f96 UIKit`_UIApplicationHandleEventQueue + 7102 
    frame #10: 0x2da7125a CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14 
    frame #11: 0x2da7072a CoreFoundation`__CFRunLoopDoSources0 + 206 
    frame #12: 0x2da6ef1e CoreFoundation`__CFRunLoopRun + 622 
    frame #13: 0x2d9d9f4e CoreFoundation`CFRunLoopRunSpecific + 522 
    frame #14: 0x2d9d9d32 CoreFoundation`CFRunLoopRunInMode + 106 
    frame #15: 0x328d3662 GraphicsServices`GSEventRunModal + 138 
    frame #16: 0x3032516c UIKit`UIApplicationMain + 1136 
    * frame #17: 0x0003b12c ChinesePod`main(argc=1, argv=0x27dccd04) + 300 at main.m:39 

我不知道什么是错的通过查看跟踪。任何想法我的应用程序有什么问题?

编辑:

当我启用NSZombie,我看到这个错误在控制台:

*** -[BlurViewController performSelector:withObject:withObject:]: message sent to deallocated instance 0x166e7df0 

的BlurViewController是一个视图控制器负责显示酥料饼的窗口。这是否意味着BlurViewController被释放? dismissDialog的

的源代码:

- (void)dismissDialog 
{ 
    [UIView animateWithDuration:kAnimationDuration animations:^{ 
     self.view.alpha = 0.f; 
     self.popUp.transform = CGAffineTransformMakeScale(0, 0); 
    } completion:^(BOOL finished) { 
     [self removeFromParentViewController]; 
     [self.view removeFromSuperview]; 
     [self.popUp removeFromSuperview]; 
     if (!self.popUp.isDownloading) { 
      _popUp = nil; 
     } 

     [UIView animateWithDuration:kAnimationDuration animations:^{ 
      _blurView.alpha = 0.f; 
     } completion:^(BOOL finished) { 
      [_blurView removeFromSuperview]; 
     }]; 
    }]; 
} 
+0

请给你使用AFNetworking下载的代码。 – DilumN

+1

您所指的某个对象已被释放。请张贴您的popover显示方法的代码。你也可以尝试运行NSZombies启用 – Paulw11

+0

@ Paulw11在Xode中启用僵尸将会有所帮助,但是使用Instruments with Zombies setup会更好...可以查看所有refcount增量和减量以及哪些代码是负责任的,每个iOS都必须知道开发商 – RobP

回答

0

呆了一天调试完毕后,我终于工作了。

以前我在我的主viewController中定义了一个BlurViewController实例作为一个方法变量,但似乎bvController是在我关闭popOver UIView之后发布的。我将bvController移至一个强大的属性,并在应用程序不再崩溃的方法中使用以下代码。

MainViewController.h: 

@property (strong, nonatomic) BlurViewController *bvController; 

MainViewController.m: 

if (!self.bvController) { 
    self.bvController = [[BlurViewController alloc] init]; 
} 

内存分配和释放在Objective-C中非常有趣。来自Java和Python的背景,我总是在这里和那里挠着脑袋。