iphone/ipad选取本地照片方法

1、iphone选取本地照片方法

UIImagePickerController *imagePickController = [[UIImagePickerController alloc]init];

imagePickController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

//picker.allowsEditing = YES;

imagePickController.delegate = self;
[self presentModalViewController:imagePickController animated:YES];
[imagePickController release]; 
        
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   
   //image就是你选取的照片
    UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
 
    [picker dismissModalViewControllerAnimated:YES];
   
   
2、ipad选取本地照片方法

            UIImagePickerController* iPickerController = [[[UIImagePickerControlleralloc] init] autorelease];

                if ([UIImagePickerControllerisSourceTypeAvailable:

                     UIImagePickerControllerSourceTypePhotoLibrary]) {

                    iPickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

                    iPickerController.delegate = self;

                    [iPickerController setAllowsEditing:NO];

                    UIPopoverController *popover = [[UIPopoverControlleralloc] initWithContentViewController:iPickerController];

                   self.popoerController = popover;

                    [popover presentPopoverFromRect:CGRectMake(180, 380, 180, 10)                inView:self.viewpermittedArrowDirections:UIPopoverArrowDirectionDownanimated:YES];

                    [popover release]; 

                }

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
   
   //image就是你选取的照片
    UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
 
    [picker dismissModalViewControllerAnimated:YES];
   
   
posted @ 2012-09-11 16:37  七夜小魔军  阅读(507)  评论(0编辑  收藏  举报