在iphone中的警报视图

时间:2010-08-10 06:37:09

标签: iphone

我遇到了提醒问题。当我在程序中添加以下内容时,显示错误:

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"That's it" message:@"THANKS FOR USING" delegate:self cancelButtonTitle:@"bye" otherButtonTitles:nil];

[alert show];   

    - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
    {
        NSLog(@"Button %d pressed", buttonIndex);
        [ alertView release ];
    }

这显示错误---- alertView未声明和预期;之前:

请帮我解决我的问题。当我点击警报按钮时,我想执行一些操作。

1 个答案:

答案 0 :(得分:5)

你在哪一行得到错误,确切的错误是什么?您是否在接口声明中添加了UIAlertViewDelegate协议?好像你没有。

您不需要在委托方法中发布alertView。您可以在显示后释放它。

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"That's it" message:@"THANKS FOR USING" delegate:self cancelButtonTitle:@"bye" otherButtonTitles:nil];
[alert show];
[alert release];
相关问题