iOS5.1 まで、Notification を受けとって UIAlertView を表示させていた以下のようなコードが、
iOS6 から、EXC_BAD_ACCESS として落ちてしまう。
UIAlertView* dialog = [[UIAlertView alloc] initWithTitle:nil
message:localString(@"msg_UnsupportFile")
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil
];
((UILabel *)[[dialog subviews] objectAtIndex:0]).textAlignment = UITextAlignmentLeft;
[dialog show];
[dialog autorelease];
メインスレッドでないとダメっぽい。
以下のようにして解決。
UIAlertView* dialog = [ [[UIAlertView alloc] autorelease] initWithTitle:nil
message:localString(@"msg_UnsupportFile")
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil
];
((UILabel *)[[dialog subviews] objectAtIndex:0]).textAlignment = UITextAlignmentLeft;
[dialog performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES ];