【问题标题】:Error using Alert Dialog使用警报对话框时出错
【发布时间】:2012-10-03 14:37:51
【问题描述】:

收到“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]”行上。谁能帮我解释一下为什么会出现这个错误以及如何解决它?谢谢。

【问题讨论】:

    标签: ios5 xcode4 uialertview


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-02-07
      • 2015-08-03
      • 1970-01-01
      • 2013-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多