应用程序崩溃[self dismissModalViewControllerAnimated:NO];

时间:2011-05-19 03:50:03

标签: iphone ipad cocos2d-iphone

在我的应用程序中我有一个UiViecontroller 当我关闭这个UiViecontroller时,我会在后面的动作中解雇ModalViewControllerAnimated:
[self dismissModalViewControllerAnimated:NO];
视图已删除,但应用程序因以下日志而崩溃。

    Thread 0 Crashed:
    0   libobjc.A.dylib                 0x34a80464 objc_msgSend + 16
    1   UIKit                           0x341aab5c _UIView + 52
    2   UIKit                           0x341aaaa8 -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 152
    3   UIKit                           0x341aaace -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 190
    4   UIKit                           0x341aaace -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 190
    5   UIKit                           0x341aaace -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 190
    6   UIKit                           0x341aa9fe -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:] + 22
    7   UIKit                           0x341aa6b8 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 304
    8   UIKit                           0x341c1724 -[UIView(Hierarchy) insertSubview:atIndex:] + 32
    9   UIKit                           0x34276c80 -[UIWindowController _transplantView:toSuperview:atIndex:] + 76
    10  UIKit                           0x34274e0e -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:] + 2522
    11  UIKit                           0x342e4368 -[UIViewController _dismissModalViewControllerWithTransition:from:] + 1472
    12  UIKit                           0x342e3868 -[UIViewController dismissModalViewControllerWithTransition:] + 376
    13  UIKit                           0x342e372e -[UIViewController dismissModalViewControllerWithTransition:] + 62
    14  UIKit                           0x342e1662 -[UIViewController dismissModalViewControllerAnimated:] + 86
    15  KabushikiShimbun                0x0005fd30 -[PDFPageScrollViewController backAction:] (PDFPageScrollViewController.m:1633)
    16  CoreFoundation                  0x35821fe6 -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
    17  UIKit                           0x341c84a6 -[UIApplication sendAction:to:from:forEvent:] + 78
    18  UIKit                           0x342637ae -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 86
    19  CoreFoundation                  0x35821fe6 -[NSObject(NSObject) performSelector:withObject:withObject:] + 18
    20  UIKit                           0x341c84a6 -[UIApplication sendAction:to:from:forEvent:] + 78
    21  UIKit                           0x341c8446 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
    22  UIKit                           0x341c8418 -[UIControl sendAction:to:forEvent:] + 32
    23  UIKit                           0x341c816a -[UIControl(Internal) <br>_sendActionsForEvents:withEvent:] + 350
    24  UIKit                           0x341c89c8 -[UIControl touchesEnded:withEvent:] + 336
    25  UIKit                           0x341be34e -[UIWindow _sendTouchesForEvent:] + 362
    26  UIKit                           0x341bdcc8 -[UIWindow sendEvent:] + 256
    27  UIKit                           0x341a8fc0 -[UIApplication sendEvent:] + 292
    28  UIKit                           0x341a8900 _UIApplicationHandleEvent + 5084
    29  GraphicsServices                0x320c8efc PurpleEventCallback + 660
    30  CoreFoundation                  0x3580f6f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
    31  CoreFoundation                  0x3580f6bc __CFRunLoopDoSource1 + 160
    32  CoreFoundation                  0x35801f76 __CFRunLoopRun + 514
    33  CoreFoundation                  0x35801c80 CFRunLoopRunSpecific + 224
    34  CoreFoundation                  0x35801b88 CFRunLoopRunInMode + 52
    35  GraphicsServices                0x320c84a4 GSEventRunModal + 108
    36  GraphicsServices                0x320c8550 GSEventRun + 56
    37  UIKit                           0x341dc322 -[UIApplication _run] + 406
    38  UIKit                           0x341d9e8c UIApplicationMain + 664
    39  KabushikiShimbun                0x00002800 main (main.m:14)
    40  KabushikiShimbun                0x000027b4 start + 32

不明白为什么 有什么建议?
谢谢。

3 个答案:

答案 0 :(得分:0)

是最初称为Modal的视图控制器? 例如,您最初是通过调用以下内容来显示视图:

[myView presentModalViewController:myViewController animated:NO];

如果你不是,那将导致你的崩溃,该应用试图通过dismissModalViewController方法摆脱不是模态的控制器。

答案 1 :(得分:0)

视图控制器的父级负责关闭其模态视图控制器。所以你应该说

[self.parentViewController dismissModalViewControllerAnimated: YES];

要了解有关展示和解除视图控制器的更多信息,请参阅我的帖子here

答案 2 :(得分:0)

确保您的模态视图控制器在您希望它解除时不会被释放。