1

私は新しいiPhone開発者です。カメラと写真ライブラリから取得した画像を画像ビューでアップロードするにはどうすればよいですか。

ありがとうございます。

4

1 に答える 1

2

これを試して。

- (IBAction)m_CtrlBtn_SelectImage_click:(id)sender
{
    if ([UIImagePickerController isSourceTypeAvailable:
         UIImagePickerControllerSourceTypePhotoLibrary]) 
    {
        // Set source to the Photo Library
        imgPicker.sourceType =UIImagePickerControllerSourceTypePhotoLibrary;// imgPicker is a  UIImagePickerController object;
        if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad) 
        {
            UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
            self.popoverController = popover;   
            [popover release];
            // popoverController.delegate = self;
            [popoverController presentPopoverFromRect:CGRectMake(0, 0, 500, 480) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];
            [imgPicker release]; 
        }
        else
        {
            [self presentModalViewController:self.imgPicker animated:YES];
        }
    }

}  
-(void)viewWillAppear:(BOOL)animated{
    self.imgPicker = [[UIImagePickerController alloc] init];
    self.imgPicker.delegate = self;

}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo { 
    m_ImgVw_SelectedImage.image=img;
    [popoverController dismissPopoverAnimated:YES];
    [picker dismissModalViewControllerAnimated:YES];
    [picker.view removeFromSuperview];
    [picker release];
    picker.delegate=nil;
}
于 2012-06-25T11:42:12.647 に答える