是什么导致我的EXC_BAD_ACCESS? (iPhone SDK)

时间:2011-08-04 18:24:57

标签: ios xcode uinavigationcontroller

- (IBAction)startSignin:(id)sender {
    Login *aview = [[Login alloc] init];
    aview.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self.navigationController presentModalViewController:aview animated:YES];

    [_window addSubview:aview.view];
    [aview release];
}

导致我的EXC BAD ACCESS的原因是什么?

每次加载登录时,只要按下该页面上的按钮或其他内容,它就会崩溃。

*** Call stack at first throw:
(
    0   CoreFoundation                      0x00dc25a9 __exceptionPreprocess + 185
    1   libobjc.A.dylib                     0x00f16313 objc_exception_throw + 44
    2   CoreFoundation                      0x00d7aef8 +[NSException raise:format:arguments:] + 136
    3   CoreFoundation                      0x00d7ae6a +[NSException raise:format:] + 58
    4   UIKit                               0x000c6709 -[UIViewController _loadViewFromNibNamed:bundle:] + 295
    5   UIKit                               0x000c4134 -[UIViewController loadView] + 120
    6   UIKit                               0x000c400e -[UIViewController view] + 56
    7   UIKit                               0x00037d42 -[UIWindow addRootViewControllerViewIfPossible] + 51
    8   Test                           0x00001b3c -[TestAppDelegate application:didFinishLaunchingWithOptions:] + 220
    9   UIKit                               0x00014c89 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1163
    10  UIKit                               0x00016d88 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 439
    11  UIKit                               0x00021617 -[UIApplication handleEvent:withNewEvent:] + 1533
    12  UIKit                               0x00019abf -[UIApplication sendEvent:] + 71
    13  UIKit                               0x0001ef2e _UIApplicationHandleEvent + 7576
    14  GraphicsServices                    0x00ffb992 PurpleEventCallback + 1550
    15  CoreFoundation                      0x00da3944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
    16  CoreFoundation                      0x00d03cf7 __CFRunLoopDoSource1 + 215
    17  CoreFoundation                      0x00d00f83 __CFRunLoopRun + 979
    18  CoreFoundation                      0x00d00840 CFRunLoopRunSpecific + 208
    19  CoreFoundation                      0x00d00761 CFRunLoopRunInMode + 97
    20  UIKit                               0x000167d2 -[UIApplication _run] + 623
    21  UIKit                               0x00022c93 UIApplicationMain + 1160
    22  Test                           0x00001a29 main + 121
    23  Test                           0x000019a5 start + 53
)
terminate called throwing an exceptionCurrent language:  auto; currently objective-c

1 个答案:

答案 0 :(得分:2)

这通常是在释放后访问对象引起的。这也是熟悉调试器的一个好点。在按钮操作方法的第一行上设置一个断点,并逐步执行它以找出哪条线是坏的。

这一次,我怀疑是addSubview:的来电,presentModal…将负责展示视图。