簡體   English   中英

UIAlertView removeFromSuperview不起作用

[英]UIAlertView removeFromSuperview does not work

我使用下面的代碼來顯示UIAlertView

UIAlertView * messageBox = [[UIAlertView alloc] initWithTitle: @"title"
                                                      message: @""
                                                     delegate: nil
                                            cancelButtonTitle: @"Cancel"
                                            otherButtonTitles: nil];



[messageBox show];

然后我使用NSNotification postNotificationName觸發並希望刪除或釋放UIAlerView

-(void)notificationEntry:(NSNotification *)notification{

    if (messageBox ) {
        //[messageBox removeFromSuperview];//this does not work neither
        [messageBox performSelectorOnMainThread:@selector(removeFromSuperview) withObject:nil waitUntilDone:NO];
        messageBox = nil;

    }
}

通知已觸發,但是

[messageBox removeFromSuperview];

[messageBox performSelectorOnMainThread:@selector(removeFromSuperview);

沒有辦法

歡迎您發表評論

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM