0

收到“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]”行上。任何人都可以帮助我了解为什么会出现此错误以及如何解决它?谢谢。

4

1 回答 1

0

我想通了。看来您必须在警报对话框中有 message:@"string" 和 CancelButtonTitle:@"string" 。

于 2012-10-03T18:09:36.170 回答