这有什么问题?我真的不明白UIImagePickerController的一些重要部分....
这里是来源:
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
imagePickerController.delegate = self;
[self presentModalViewController:imagePickerController animated:YES];
[imagePickerController release];
Run Code Online (Sandbox Code Playgroud)
我不能打开照片库吗?任何帮助赞赏!
我知道这个帖子以前存在,但是因为只出现在iOS5 beta 6中而被关闭.到现在为止,我的手机上已经有了iOS 5的Golden Master,但仍然出现了这个错误.
当我创建一个这是发生UIImagePickerController了sourceType的UIImagePickerControllerSourceTypePhotoLibrary5倍以上.据我所知,每次都正确创建和释放以前的UIImagePickerController.
编辑:根据要求添加代码.
UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:ipc animated:YES];
[ipc release];
Run Code Online (Sandbox Code Playgroud)
后来,我打电话[self dismissModalViewControllerAnimated:YES];的时候-imagePickerController:didFinishPickingImage:editingInfo:被调用.
我对使用UIImagePickerController整个屏幕的摄像机控件的自定义叠加感兴趣,非常类似于切换到视频功能时默认的摄像头应用程序所做的操作.
关于这个主题,我在这里引用了几个问题,尤其是这个问题,以及关于如何为UIImagePickerController使用自定义叠加层的Apple示例,但是它们都没有能够产生成功的全屏结果IOS 7.
到目前为止,这是相机UI与自定义叠加层(没有任何按钮)的样子:

请注意,屏幕底部有一个黑条.我注意到如果我将其更改为1,我可以删除黑条cameraAspectRatio,但是这会使相机变焦,因为它具有非常放大的视图.有没有办法让全屏没有太多扭曲变焦(我明白一点点是必要的),还删除黑条?
这是我配置自定义叠加层的代码:
{
self.imagePickerController.showsCameraControls = NO;
[[NSBundle mainBundle] loadNibNamed:@"overlayView" owner:self options:nil];
self.overlayView.frame = self.imagePickerController.cameraOverlayView.frame;
self.imagePickerController.cameraOverlayView = self.overlayView;
self.overlayView = nil;
// Device's screen size (ignoring rotation intentionally):
CGSize screenSize = [[UIScreen mainScreen] bounds].size;
float cameraAspectRatio = 4.0 / 3.0; //! Note: 4.0 and 4.0 works
float imageWidth = floorf(screenSize.width * cameraAspectRatio);
float scale = ceilf((screenSize.height / imageWidth) * 10.0) / 10.0;
self.imagePickerController.cameraViewTransform = CGAffineTransformMakeScale(scale, scale);
} …Run Code Online (Sandbox Code Playgroud) 我正在使用UIImagePickerController来允许用户拍照.我想让他之后编辑它,但无论我做什么,我什么也得不到.这是我的代码(我正在使用Xamarin):
UIImagePickerController imagePicker = new UIImagePickerController ();
// set our source to the camera
imagePicker.SourceType = UIImagePickerControllerSourceType.Camera;
// set what media types
//imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes (UIImagePickerControllerSourceType.Camera);
// show the camera controls
imagePicker.ModalPresentationStyle = UIModalPresentationStyle.CurrentContext;
imagePicker.ShowsCameraControls = true;
imagePicker.AllowsEditing = true;
imagePicker.SetEditing (true,true);
imagePicker.PreferredContentSize = new SizeF(900,600);
imagePicker.CameraCaptureMode = UIImagePickerControllerCameraCaptureMode.Photo;
imagePicker.Title="taste.eat. image";
// attach the delegate
imagePicker.Delegate = new ImagePickerDelegate();
// show the picker
NavigationController.PresentViewController(imagePicker, true,null);
Run Code Online (Sandbox Code Playgroud)
我错过了什么吗?
编辑:
我已经按照教程进行了操作,并且我正在使用矩形进入屏幕,但是如果我平移或缩放它,只要我抬起手指就会快速回到中心.是否可以从照片应用程序进入此屏幕?

我需要使用SwiftUI在应用程序中打开ImagePicker,该怎么办?
我曾考虑过使用UIImagePickerController,但是我不知道如何在SwiftUI中做到这一点。
我已经提到了这个非常好的参考:https://stackoverflow.com/questions/1282830/uiimagepickercontroller-uiimage-memory-and-more但我有一些非常严重的问题.我拍照后,收到内存警告.这是我拍的第一张照片,而不是第二张或第三张照片.
我想知道是不是因为我从应用程序目录中加载了几个小jpeg到滚动视图中.我能想到的唯一解决方案是在UIImagePicker处于活动状态时卸载主视图中的所有内容,然后重新加载所有内容,但我不确定这是正确的解决方案,我不知道该怎么做.
UIImagePicker会占用那么多内存吗?我甚至没有处理或显示它所需的图像.即使我把图像丢掉,我也会得到记忆警告.
任何帮助赞赏.
我编写了简单的代码来测试UIImagePickerController:
@implementation ProfileEditViewController
- (void)viewDidLoad {
[super viewDidLoad];
photoTaker_ = [[UIImagePickerController alloc] init];
photoTaker_.delegate = self;
photoTaker_.sourceType = UIImagePickerControllerSourceTypeCamera;
photoTaker_.showsCameraControls = NO;
}
- (void)viewDidAppear: (BOOL)animated {
[self presentModalViewController: photoTaker_ animated: NO];
}
@end
Run Code Online (Sandbox Code Playgroud)
我收到如下奇怪的警告:
2010-05-20 17:53:13.838 TestProj [2814:307]使用两阶段旋转动画.要使用更平滑的单阶段动画,此应用程序必须删除两阶段方法实现.2010-05-20 17:53:13.849 TestProj [2814:307]旋转多个视图控制器或视图控制器而不是窗口委托时,不支持使用两阶段旋转动画
知道这是关于什么的吗?非常感谢提前!
任何人在尝试使用图像选择器访问照片库之前遇到此错误?
NSInvalidArgumentException Cannot set metadata in read-only store.
Run Code Online (Sandbox Code Playgroud)
任何关于实际出错的建议以及如何解决这个问题的建议将不胜感激.
错误堆栈的快照如下所示

我正在实施一个流程,用户可以从库中选择照片或使用相机拍照.当我以模态方式呈现UIImagePickerController时,我必须要去:
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
Run Code Online (Sandbox Code Playgroud)
要么
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
Run Code Online (Sandbox Code Playgroud)
这意味着展示一个"脚手架控制器",用户可以从中选择他们的图书馆或相机.我发现大多数具有此类功能的应用程序直接进入Camera控制器,但显示一个按钮,用于从库中进行选择.
我可以找到的所有示例/教程,包括Apple的PhotoPicker源,都可以从摄像机或库中选择这个空的viewController - 但我检查的所有应用都是"直接到摄像机 - 可以选择进入库".
如何将照片库按钮选项添加到相机工具栏?
(app> = iOS 4.3)
谢谢你给予的任何帮助.
我的下面的代码与swift 4工作得很好但升级到swift 4.2后我收到了这个错误,我浪费了3个小时搜索问题但是失败了.如果有人可以指导我如何解决这个问题.
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
if postType == 2 {
let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey)] as! UIImage
mediaType.image = image
} else {
videoURL = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.mediaURL)] as? URL
do {
let asset = AVURLAsset(url: videoURL!, options: nil)
let imgGenerator = AVAssetImageGenerator(asset: asset)
imgGenerator.appliesPreferredTrackTransform = true
let cgImage = try imgGenerator.copyCGImage(at: CMTime.init(value: 0, timescale: 1), actualTime: nil)
let thumbnail = UIImage(cgImage: cgImage)
self.mediaType.image = thumbnail
} catch {
print("*** Error generating thumbnail: \(error)")
} …Run Code Online (Sandbox Code Playgroud) ios ×7
iphone ×5
swift ×2
camera ×1
ios12 ×1
ios7 ×1
memory ×1
objective-c ×1
photolibrary ×1
swiftui ×1
xamarin ×1
xamarin.ios ×1