问题描述
- ipad将图片放到UIPopoverController中
- 我的目标是让用户能从
UIWebView
抓取屏幕截图。然后将图片加载到UIPopoverController
中。在
UIPopoverController
中用户可剪裁并保存图片。目前我实现了UIImage屏幕截图。然后
UIPopoverController
弹出,但是不能保存图片,好像是由于这句代码:imagePicker sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
应该怎么修改呢?全部代码:
-(UIImage*)captureScreen:(UIView*) viewToCapture{ UIGraphicsBeginImageContext(viewToCapture.bounds.size); [viewToCapture.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); imageView.image = viewImage; [imageView setHidden:NO]; // this removes current view ie photoLibary [self dismissViewControllerAnimated:YES completion:NULL]; // this checks that a popover is not already in view if ([popoverController isPopoverVisible]) { // if yes - remove [popoverController dismissPopoverAnimated:YES]; } else { // create an imagePicker UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init]; imagePicker.delegate = self; imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; imagePicker.allowsEditing = YES; // create an PopoverController popoverController = [[UIPopoverController alloc] initWithContentViewController:imagePicker]; popoverController.delegate = self; UIView *popView = [[UIView alloc]initWithFrame:CGRectMake(0 0 500 500)]; [self.view addSubview:popView]; [popoverController presentPopoverFromRect:CGRectMake(100200 565 545) inView:self.view permittedArrowDirections:0 animated:YES]; } return viewImage;}
解决方案
http://www.cnblogs.com/ios-wmm/archive/2012/09/03/2668885.html
时间: 2025-01-25 13:01:55