[英]when i set delegate.self in uialertview application is crash in arc
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Order"
message:@"Order Successfully Discontinued."
delegate:self
cancelButtonTitle:nil
otherButtonTitles: @"Ok",nil];
//[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
alertView.tag=TAG_DEV;
[alertView show];
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
if(alertView.tag==TAG_DEV)
{
if(buttonIndex==0)
{
}
else
NSLog(@"Here");
}
}
這崩潰了。 我該如何解決?
當您在“ objc_msgSend()”上崩潰時,您很可能向已釋放的對象發送消息。 或者您有一個正確的指針,但是某些東西改變了對象的內容。 另一個原因可能是使用了懸空指針,該指針曾經指向對象現在占用的內存。 有時objc_msgSend崩潰是因為內存錯誤更改了運行時自己的數據結構,然后這會給接收器對象本身造成麻煩。
在這種情況下,您是否需要檢查,UIAlertview的委托在呈現后已被釋放,因此,在解除警報時,它不會向其委托發送消息,這可能為零。 另一個選擇是,呈現警報視圖的UIViewController在呈現后被釋放。 出現警報代理后,請檢查是否未釋放。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.