`

iPad上调用UIImagePickerViewController,与iPhone调用略有不同。

    博客分类:
  • IOS
 
阅读更多
-(void) pickImage{
    UIImagePickerController *m_imagePicker = [[UIImagePickerController alloc] init];
    if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
        m_imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        m_imagePicker.delegate = self;
        [m_imagePicker setAllowsEditing:NO];
        UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:m_imagePicker];
        self.popoverController = popover;        
        [popoverController presentPopoverFromRect:CGRectMake(0, 0, 300, 300) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
        [popover release];
        [m_imagePicker release];
    }else {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:@"Error accessing photo library!" delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
        [alert show];
        [alert release];
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics