在两个视图控制器之间切换时发生崩溃。基本上布局就是这样的 - >向右滑动以显示顶部View Controller下方的左侧菜单视图 - >启动应用程序后,将首先检查您的身份验证,一旦UIAlertView从服务器获得响应,就会显示UIAlertView,以确定您未经过身份验证。
如果在认证过程中我向右滑动以显示下方的左侧菜单视图控制器,然后选择它以在顶视图控制器返回之前启动新的视图控制器,它将加载我的第二个视图控制器但是它将显示该屏幕上的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];
}
}
答案 0 :(得分:0)
是的,你是对的。禁用顶视图控制器的滑动操作,直到在身份验证期间从服务器获得响应。根据响应启用滑动操作一次。
答案 1 :(得分:0)
这解决了这个问题,我再也无法让它崩溃了。
- (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];
}
}