0
  if (! self.mainPage)
{ self.mainPage= [[MainGameDisplay alloc] initWithNibName:nil bundle:nil]; }
[self presentViewController: self.mainPage animated:YES completion:NULL];

[self.view addSubview:self.mainPage.view];
self.mainPage.view.frame = CGRectMake(568, 0, 568, 320);//(N = horizontal, N = vertical)
[UIView animateWithDuration:1.0f
                 animations:^{
                     //actual frame needed with an animation.
                     self.mainPage.view.frame = CGRectMake(0, 0, 568, 320);
                 }
                 completion:^(BOOL finished) {
                     //ENTER HERE ANYTHING TO RUN AFTER ANIMATION IS COMPLETED:
                     [self presentViewController: self.mainPage animated:NO completion:NULL];
                     //This will make the next page load correctly after the transition, otherwise you cannot. interact with anything.
                 }];

@property (strong) MainGameDisplay *mainPage;

在 .h 文件中声明。这段代码完美运行,但只有一次,如果我要转换到 mainPage 视图,返回并再次转换到那里,它会在转换结束时崩溃。我已经玩了很多来解决这个问题,但它就是行不通。

================= MainGameDisplay viewDidLoad 的堆栈跟踪:

//First transition, A-Okay.
2012-11-11 12:27:07.547 Test_Game [584:c07] (
    0   Test_Game                              0x00002dab -[MainGameDisplay viewDidLoad] + 91
    1   UIKit                               0x000f8817 -[UIViewController loadViewIfRequired] + 536
    2   UIKit                               0x000f8882 -[UIViewController view] + 33
    3   Test_Game                              0x0000240e -[ViewController StartGame:] + 334
    4   libobjc.A.dylib                     0x010e3705 -[NSObject performSelector:withObject:withObject:] + 77
    5   UIKit                               0x0001a920 -[UIApplication sendAction:to:from:forEvent:] + 96
    6   UIKit                               0x0001a8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    7   UIKit                               0x000db671 -[UIControl sendAction:to:forEvent:] + 66
    8   UIKit                               0x000dbbcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
    9   UIKit                               0x000dad38 -[UIControl touchesEnded:withEvent:] + 546
    10  UIKit                               0x0004a33f -[UIWindow _sendTouchesForEvent:] + 846
    11  UIKit                               0x0004a552 -[UIWindow sendEvent:] + 273
    12  UIKit                               0x000283aa -[UIApplication sendEvent:] + 436
    13  UIKit                               0x00019cf8 _UIApplicationHandleEvent + 9874
    14  GraphicsServices                    0x01beddf9 _PurpleEventCallback + 339
    15  GraphicsServices                    0x01bedad0 PurpleEventCallback + 46
    16  CoreFoundation                      0x01c07bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    17  CoreFoundation                      0x01c07962 __CFRunLoopDoSource1 + 146
    18  CoreFoundation                      0x01c38bb6 __CFRunLoopRun + 2118
    19  CoreFoundation                      0x01c37f44 CFRunLoopRunSpecific + 276
    20  CoreFoundation                      0x01c37e1b CFRunLoopRunInMode + 123
    21  GraphicsServices                    0x01bec7e3 GSEventRunModal + 88
    22  GraphicsServices                    0x01bec668 GSEventRun + 104
    23  UIKit                               0x0001765c UIApplicationMain + 1211
    24  Test_Game                              0x00001cfd main + 141
    25  Test_Game                              0x00001c25 start + 53
)



//Second transition, crashes now.
2012-11-11 12:27:11.223 Test_Game [584:c07] (
    0   Test_Game                            0x00002dab -[MainGameDisplay viewDidLoad] + 91
    1   UIKit                               0x000f8817 -[UIViewController loadViewIfRequired] + 536
    2   UIKit                               0x000f8882 -[UIViewController view] + 33
    3   Test_Game                              0x0000240e -[ViewController StartGame:] + 334
    4   libobjc.A.dylib                     0x010e3705 -[NSObject performSelector:withObject:withObject:] + 77
    5   UIKit                               0x0001a920 -[UIApplication sendAction:to:from:forEvent:] + 96
    6   UIKit                               0x0001a8b8 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 61
    7   UIKit                               0x000db671 -[UIControl sendAction:to:forEvent:] + 66
    8   UIKit                               0x000dbbcf -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 578
    9   UIKit                               0x000dad38 -[UIControl touchesEnded:withEvent:] + 546
    10  UIKit                               0x0004a33f -[UIWindow _sendTouchesForEvent:] + 846
    11  UIKit                               0x0004a552 -[UIWindow sendEvent:] + 273
    12  UIKit                               0x000283aa -[UIApplication sendEvent:] + 436
    13  UIKit                               0x00019cf8 _UIApplicationHandleEvent + 9874
    14  GraphicsServices                    0x01beddf9 _PurpleEventCallback + 339
    15  GraphicsServices                    0x01bedad0 PurpleEventCallback + 46
    16  CoreFoundation                      0x01c07bf5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    17  CoreFoundation                      0x01c07962 __CFRunLoopDoSource1 + 146
    18  CoreFoundation                      0x01c38bb6 __CFRunLoopRun + 2118
    19  CoreFoundation                      0x01c37f44 CFRunLoopRunSpecific + 276
    20  CoreFoundation                      0x01c37e1b CFRunLoopRunInMode + 123
    21  GraphicsServices                    0x01bec7e3 GSEventRunModal + 88
    22  GraphicsServices                    0x01bec668 GSEventRun + 104
    23  UIKit                               0x0001765c UIApplicationMain + 1211
    24  Test_Game                              0x00001cfd main + 141
    25  Test_Game                              0x00001c25 start + 53
)
4

1 回答 1

0

也许你在 viewDidDisapear 或类似的东西中释放你的财产?什么类型的崩溃 - BAD_ACCESS?

于 2012-11-11T13:06:06.407 回答