我在兩個視圖控制器之間切換時發生崩潰。基本上佈局是這樣的 - >向右滑動以顯示頂部下方的左側菜單視圖控制器 - >啓動後,應用程序將首先檢查您的身份驗證,一旦UIAlertView獲得響應,它將顯示從服務器中確定您沒有通過身份驗證。切換視圖控制器時iOS崩潰
如果在身份驗證過程中向右滑動以顯示下方的左側菜單視圖控制器,然後選擇它以在頂部視圖控制器返回之前啓動新的視圖控制器將加載我的第二個視圖控制器,但隨後會顯示該屏幕上的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
這裏是頂視圖控制器,相信還是會通過其將它們設置爲nil解決這個問題對我的dealloc方法:
- (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];
}
}
是否使用ARC? – rdelmar 2013-04-28 01:55:26
是該項目正在使用ARC。 – Jarod 2013-04-28 02:28:36
我編輯了我的問題,我認爲這可能至少是一個解決辦法,所以它不會崩潰。 – Jarod 2013-04-28 02:41:59