相机点击图像的标题和说明

时间:2012-11-30 06:39:13

标签: iphone objective-c ios xcode uiimagepickercontroller

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

- (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];
}

2 个答案:

答案 0 :(得分:0)

您可以通过以下方式完成此操作:

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

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

希望它对你有所帮助。

More Help Here....

答案 1 :(得分: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;
    }
}