使用警报对话框时出错

时间:2012-10-03 14:37:52

标签: ios5 xcode4 uialertview

接收“UIAlertView没有可见的@interface声明选择器'message:delegate:otherButtonTitles'”。我正在尝试设置一个2按钮警告对话框,以便在用户选择图像后显示。我在.h文件中有UIAlertDelegate。以下是带有警告对话框的图像选取代码:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    [[UIApplication sharedApplication]setStatusBarHidden:YES];
    [self dismissModalViewControllerAnimated:YES];
    UIImage *originalImage = [info objectForKey:UIImagePickerControllerOriginalImage];
    NSData *imageData = UIImagePNGRepresentation(originalImage);
    NSString* imageName = @"yourPhoto.png";
    NSString* paths = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0];
    NSString* fullPathToFile = [paths stringByAppendingPathComponent:imageName];
    [imageData writeToFile:fullPathToFile atomically:NO];

UIAlertView *dir;
dir = [[[UIAlertView alloc]
        message:@"Choose the direction."
        delegate:self
        otherButtonTitles:@"Left",@"Right",nil];
[dir show];
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [[UIApplication sharedApplication] setStatusBarHidden:YES];
    [self dismissModalViewControllerAnimated:YES];
}

错误显示在“dir = [[UIAlertView alloc]”行上。任何人都可以帮我解决为什么我收到此错误以及如何修复它?谢谢。

1 个答案:

答案 0 :(得分:0)

我明白了。看来你必须在警告对话框中输入消息:@“string”和CancelButtonTitle:@“string”。