2

我有这个代码:

//显示警报

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Actualizado" 
message:@"Se ha actualizado todo" delegate:self 
cancelButtonTitle:@"Aceptar" otherButtonTitles:nil, nil];
[alert show];

和这个

- (void)alertView:(UIAlertView *)alert 
clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"ALgo"); }

并得到以下错误:

 -[__NSCFType alertView:clickedButtonAtIndex:]:
unrecognized selector sent to instance 0xdc559a0

请帮忙。谢谢

4

4 回答 4

4

看起来您可能正在释放处理alertView:clickedButtonAtIndex:选择器(委托)的对象或视图。确保您保留它,直到您的UIAlertView处理完毕。

于 2012-05-10T18:29:45.470 回答
0

您是否已将 UIAlertViewDelegate 添加到您的头文件中?例如@interface yourclass: UIViewController 检查这是否可能是原因

于 2012-05-10T18:46:47.397 回答
0
UIAlertView *alert = [[UIAlertView alloc]  initWithTitle:@"Actualizado" message:@"Se ha actualizado todo" delegate:self cancelButtonTitle:@"Aceptar" otherButtonTitles:nil, nil];

尝试这个

于 2012-05-10T18:17:45.960 回答
0

如果您的 alertView 是在从 ViewController 实例化的对象中创建的,则需要在 ViewController 中保留指向该对象的指针。

于 2014-03-20T18:29:31.717 回答