在两个视图控制器之间切换时发生崩溃。基本上布局是这样的 --> 向右滑动以显示顶部视图控制器下方的左侧菜单视图 --> 启动应用程序时,最初会检查您的身份验证,一旦从服务器以识别您未通过身份验证。
如果在身份验证期间我向右滑动以显示下方的左侧菜单视图控制器,然后选择它以在顶部视图控制器返回之前启动新的视图控制器,它将加载我的第二个视图控制器,但随后它将显示 UIAlertView用于已关闭的顶视图控制器的屏幕。因此,当您单击按钮以关闭该 UIAlertView 时,它会使应用程序崩溃。这是崩溃线程0:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x3bcc75b0 objc_msgSend + 16
1 UIKit 0x35f03c4c -[UIAlertView(Private) _buttonClicked:] + 292
2 UIKit 0x35e970c0 -[UIApplication sendAction:to:from:forEvent:] + 68
3 UIKit 0x35e97072 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 26
4 UIKit 0x35e97050 -[UIControl sendAction:to:forEvent:] + 40
5 UIKit 0x35e96906 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 498
6 UIKit 0x35e96dfc -[UIControl touchesEnded:withEvent:] + 484
7 UIKit 0x35dbf5ec -[UIWindow _sendTouchesForEvent:] + 520
8 UIKit 0x35dac7fc -[UIApplication sendEvent:] + 376
9 UIKit 0x35dac116 _UIApplicationHandleEvent + 6150
10 GraphicsServices 0x37ac45a0 _PurpleEventCallback + 588
11 GraphicsServices 0x37ac41ce PurpleEventCallback + 30
12 CoreFoundation 0x33f79170 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
13 CoreFoundation 0x33f79112 __CFRunLoopDoSource1 + 134
14 CoreFoundation 0x33f77f94 __CFRunLoopRun + 1380
15 CoreFoundation 0x33eeaeb8 CFRunLoopRunSpecific + 352
16 CoreFoundation 0x33eead44 CFRunLoopRunInMode + 100
17 GraphicsServices 0x37ac32e6 GSEventRunModal + 70
18 UIKit 0x35e002fc UIApplicationMain + 1116
19 iShame 0x000bbe90 main (main.m:16)
20 libdyld.dylib 0x3c103b1c start + 0
这是我在顶视图控制器上的 dealloc 方法,我认为可以通过将它们设置为 nil 来解决问题:
- (void)dealloc
{
noConnection = nil;
userSetup = nil;
userExist = nil;
accountAlertView = nil;
confirmed = nil;
login = nil;
if (_connection)
{
[_connection cancel];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}
任何关于去哪里的方向都将不胜感激。我现在唯一能想到的基本上是禁用滑动操作和显示菜单的菜单按钮,直到它从服务器收到有关用户身份验证状态的通知。请问有什么想法吗?
潜在的解决方法:
- (void)dealloc
{
[noConnection dismissWithClickedButtonIndex:0 animated:YES];// = nil;
[userSetup dismissWithClickedButtonIndex:0 animated:YES]; //= nil;
[userExist dismissWithClickedButtonIndex:0 animated:YES]; //= nil;
[accountAlertView dismissWithClickedButtonIndex:0 animated:YES]; //= nil;
[confirmed dismissWithClickedButtonIndex:0 animated:YES]; //= nil;
[login dismissWithClickedButtonIndex:0 animated:YES]; //= nil;
if (_connection)
{
[_connection cancel];
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
}