UIAlertView removeFromSuperview不起作用

时间:2014-01-17 02:22:24

标签: ios

我使用下面的代码来显示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);

无效

您的评论欢迎

1 个答案:

答案 0 :(得分:4)