2012-11-28 13 views
8

私はUIAlertViewのプライベートメソッドによって引き起こされたクラッシュを把握しようとしています。私のアプリケーションのクラッシュの約半分がこれに関係しています。奇妙なUIAlertViewプライベートメソッドクラッシュ_performPopup

ここに私のクラッシュレポートのセクションがあります。私の気になるところは、ほとんどの私のアラートビューが、アプリのライフサイクル全体に存在するように設計されたシングルトンオブジェクトによってポップされるということです。だから、これがUIAlertViewの代理人によって呼び出される前に解放されることが原因であるかどうかはわかりません。誰もこれを見たことがありますか?あなたがアドバイスしていただけますか?ありがとう。

Hardware Model:  iPhone4,1 
Version:   ??? (???) 
Code Type:  ARM (Native) 
Parent Process: launchd [1] 

Date/Time:  2012-11-15 11:31:57.452 -0800 
OS Version:  iOS 6.0.1 (10A523) 
Report Version: 104 

Exception Type: EXC_BAD_ACCESS (SIGSEGV) 
Exception Codes: KERN_INVALID_ADDRESS at 0x5354440a 
Crashed Thread: 0 

Thread 0 name: Dispatch queue: com.apple.main-thread 
Thread 0 Crashed: 
0 libobjc.A.dylib     0x33ab95b6 objc_msgSend + 22 
1 UIKit       0x32e52fa0 -[UIAlertView(Private) _performPopup:animationType:revealedBySpringBoardAlert:] 
2 UIKit       0x330621c4 -[UIAlertView(Private) _repopupNoAnimation] 
3 UIKit       0x33065b38 __36-[_UIAlertStackWatcher _appResumed:]_block_invoke_0 
4 libdispatch.dylib    0x37ec211c _dispatch_call_block_and_release 
5 libdispatch.dylib    0x37ec14b4 _dispatch_client_callout 
6 libdispatch.dylib    0x37ec61b8 _dispatch_main_queue_callback_4CF$VARIANT$mp 
7 CoreFoundation     0x39ba2f36 __CFRunLoopRun 
8 CoreFoundation     0x39b15eb8 CFRunLoopRunSpecific 
9 CoreFoundation     0x39b15d44 CFRunLoopRunInMode 
10 GraphicsServices    0x37ee32e6 GSEventRunModal 
11 UIKit       0x32d552f4 UIApplicationMain 
12 MYAPP       0x0000334a main + 70 
13 MYAPP       0x000032fc start + 36 
+0

uは –

+1

参照ポストalertview作成するためのコードを共有することができます。http:// stackoverflow.com/questions/2581081/uialertview-crashing-on-undocumented-method – petert

答えて

3

ここでは、デリゲートが問題を引き起こしているようです。ユーザー入力を追跡する必要がない単純なUIAlertViewsについて、あなただけのような、nilにデリゲートを設定することができます。

あなたはちょうどあなたがUIAlertViewのデリゲートときにnilを確認して、デリゲートメソッドを必要とした場合は
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"My Alert" message: @"My Message" delegate: nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
[alert show]; 

表示を失う:

alert.delegate = nil; 

deallocまたはおそらくviewWillDisappearのいずれか:あなたのコードがどのように設定されているかによって!

0

また、アプリがバックグラウンドになったときにアラートビューを閉じたり消したりするのも良い考えです。

viewDidLoadメソッドに以下を追加します。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleApplicationDidEnterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil]; 

をhandleApplicationDidEnterBackgroundの実装後、次のようになります。

- (void)handleApplicationDidEnterBackground:(NSNotification *)n 
{ 
    if (self.alertView) 
    { 
     self.alertView.delegate = nil; 
     [self.alertView dismissWithClickedButtonIndex:[self.alertView cancelButtonIndex] animated:NO]; 
     self.alertView = nil; 
    } 
}