1

在我的相机应用程序中,当我单击图像时,它会向用户询问标题和描述,然后保存它。现在它正在保存图像,但不询问标题和描述。我是 iOS 的新手。所以,可能是这样是一个愚蠢的问题。请帮助我得到这个。对于相机点击我正在使用这种方法:-

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

BOOL camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
if(camera)
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    [[picker navigationBar]setBarStyle:UIBarStyleDefault];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    [picker setDelegate:self];
    [self presentViewController:picker animated:YES completion:NULL];

    [picker release];
}
4

2 回答 2

0

您可以通过以下方式执行此操作:

  • 使用相机单击图像。
  • 在不保存图像的情况下返回您的应用程序。到目前为止,您将获得在您的应用程序中单击的图像的引用。
  • 向用户询问标题和描述。
  • 使用这行代码将图像保存到图片库:

    UIImageWriteToSavedPhotosAlbum(UIImage *image, id completionTarget, SEL completionSelector, void contextInfo);

希望它可以帮助你。

更多帮助在这里....

于 2012-11-30T10:57:17.023 回答
0

对我来说,本教程指导我实现了我想要的。所以,我想分享链接。可能有人从中受益。

http://www.raywenderlich.com/13541/how-to-create-an-app-like-instagram-with-a-web-service-backend-part-22

这段代码可以帮助我..

-(void) takePhoto{
    BOOL camera = [UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera];
    if(camera)
    {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        [[picker navigationBar]setBarStyle:UIBarStyleDefault];
        picker.sourceType = UIImagePickerControllerSourceTypeCamera;
        [picker setDelegate:self];
        [self presentViewController:picker animated:YES completion:NULL];
        [picker release];
        actionSheetbool = false;
    }

    else
    {
        UIAlertView* cameraAlert = [[UIAlertView alloc]initWithTitle:@"Sorry!!" message:@"Camera not found." delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
        [cameraAlert show];
        [cameraAlert release];
    }

}
-(void)photoLibrary{
    if ([UIImagePickerController isSourceTypeAvailable:
         UIImagePickerControllerSourceTypeSavedPhotosAlbum])
    {
        UIImagePickerController *imagePicker =
        [[UIImagePickerController alloc] init];
        imagePicker.delegate = self;
        imagePicker.sourceType =
        UIImagePickerControllerSourceTypePhotoLibrary;
        imagePicker.allowsEditing = YES;
        [self presentViewController:imagePicker animated:YES completion:nil];
        [imagePicker release];
        actionSheetbool = false;
    }
}
于 2013-04-16T06:30:50.137 回答