2012-11-11 38 views
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 
) 
+0

发布stacktrace。 – trojanfoe

+0

你能解决你的问题吗? –

回答

0

也许你relese你财产viewDidDisapear或这样的事情? 什么类型的崩溃 - BAD_ACCESS?

+0

我正在使用ARC,所以编译器应该为我做,如果有必要。 – PappaSmalls

+0

MainGameDisplay中91行的代码是什么?因为我在viewDidLoad中看到问题 - [MainGameDisplay viewDidLoad] + 91 – sacred

+0

一个用时间做的方法,这不是问题,因为在我使用这个方法之前它没有工作。 – PappaSmalls