我正在解雇模态视图控制器然后立即呈现另一个,但后者永远不会发生.这是代码:
[self dismissModalViewControllerAnimated:YES]; UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; [self presentModalViewController:picker animated:YES];
第一个模态VC向下滑动,但新的picker永远不会出现.知道发生了什么事吗?
我有一个应用程序,允许用户从他们的设备中选择一张照片.要做到这一点,我正在使用UIImagePickerController,但问题是我不确定我是否应该使用源类型UIImagePickerControllerSourceTypePhotoLibrary或UIImagePickerControllerSourceTypeSavedPhotosAlbum.
在运行iOS 5的iPhone 4上,保存的照片相册提供了更好的体验,但是当我尝试使用我从iTunes同步的照片运行iOS 4.3的iPod Touch时,它甚至都没有显示出来.如果我切换到PhotoLibrary我的iPod工作,但我的iPhone体验更糟.当我问UIImagePickerController它说SavedPhotosAlbum我的iPod上有可用的,但我似乎没有办法确定它是空的.
确定使用哪种源类型的最佳方法是什么?如果我有办法确定保存的相册是否为空,我想这可行,但我没有看到.
我有一个非常简单的应用程序: - 只允许屏幕上的按钮允许所有方向 - 按钮显示UIImagePickerController(拍照) - 使用Xcode 5和SDK 7构建
在iOS 8上,UIImagePickerController无论我是横向还是纵向,相机都正确显示,但是当我旋转设备时,我将相机视图旋转了90度,这是一个例子:
UIImagePickerController
视图是横向的,但相机旋转了90度
其他人是否已经遇到过此问题?
PS:如果我拍照(再次在风景中),照片正确拍摄并现在正确显示:

编辑
这个错误似乎在运行iOS 8.1的iPad上修复,但似乎没有任何与iOS 8.1发行说明中的错误相关的内容:https://developer.apple.com/library/content/releasenotes/General/RN-iOSSDK-8.1/
感谢所有早期版本的iOS 8的修复程序!
objective-c uiimagepickercontroller screen-rotation ios ios8
我使用UIImagePickerController通过iPhone的相机拍照.
我想展示两张"拍照"和"选择一张照片".
我的代码
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .camera
//imagePicker.sourceType = .PhotoLibrary
presentViewController(imagePicker, animated: true, completion: nil)
Run Code Online (Sandbox Code Playgroud)
我试图使用imagePicker.sourceType = .Camera和imagePicker.sourceType = .PhotoLibrary一起做这一点,但它不工作...
谢谢
当我尝试从照片库中读取图像时,我收到错误消息"超过最多5个过滤的专辑列表试图注册.这将失败." 图像未读取.
知道如何解决这个问题吗?
在我为OCR翻译应用程序编写的一些快速代码中遇到问题.代码段如下:
@IBAction func btnOCR(sender: AnyObject) {
var languageAlert = UIAlertController(title: "For Your Information...", message: "The OCR feature currently only supports English & French.", preferredStyle: .Alert)
languageAlert.addAction(UIAlertAction(title: "Okay", style: .Default, handler: { action in
var image = UIImagePickerController()
image.sourceType = UIImagePickerControllerSourceType.Camera
image.allowsEditing = false
image.delegate = self
presentViewController(image, animated: true, completion: nil)
}))
self.presentViewController(languageAlert, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)
image.delegate = self行返回错误:无法将类型viewcontroller的值赋给uiimagepickerdelegate.
我在类定义中设置了委托,这可以在下面看到......
class ViewController: UIViewController, UITextFieldDelegate, UIPickerViewDelegate, UIPickerViewDataSource, UIImagePickerControllerDelegate { }
Run Code Online (Sandbox Code Playgroud)
所有和任何帮助将不胜感激,提前感谢.
UIImagePickerController具有以下源类型常量:
UIImagePickerControllerSourceTypePhotoLibrary
UIImagePickerControllerSourceTypeSavedPhotosAlbum
Run Code Online (Sandbox Code Playgroud)
文档说一个用于照片库,另一个用于相机胶卷.
这两者之间的确切区别是什么?"照片库"是否也包含用相机拍摄的照片?
我正在尝试UIImagePickerController快速使用但不工作......
我的ViewController:
class ViewController: UIViewController {
@IBOutlet var imag : UIView = nil
@IBAction func capture(sender : UIButton) {
println("Button capture")
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)
{
var imag = UIImagePickerController()
imag.delegate = self
imag.sourceType = UIImagePickerControllerSourceType.Camera;
imag.mediaTypes = kUTTypeImage
imag.allowsEditing = false
self.presentViewController(imag, animated: true, completion: nil)
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在下面的代码行中有错误
imag.delegate = self
(Type'ViewControlles does confoorm to protocol 'UIImagePickerControllerDelegate')
imagePicker.mediaTypes = kUTTypeImage
(use of unresolved identifier kUTTypeImage)
Run Code Online (Sandbox Code Playgroud)
我已经阅读过kUTTypeImage在swift 中无法使用的内容.但是我不知道,我正在使用这个函数.有帮助吗?
谢谢!!
我发现,在编译iOS 8(并在iOS 8中运行)时,UIWebView如果在UIWebView模式中呈现的视图控制器中,则无法显示相机/图像选择器.它在视图控制器中直接从窗口"悬挂" rootViewController或从其推出的视图控制器中工作没有问题.
测试应用程序可以在https://dl.dropboxusercontent.com/u/6214425/TestModalWebCamera.zip找到,但我将在下面进行描述.
我的测试应用程序(使用故事板构建,但实际应用程序不使用它们)有两个视图控制器(非原始命名ViewController和ViewController2).ViewController包含在UINavigationController根视图控制器中.ViewController包含一个UIWebView(工作正常),一个"显示"("推")的按钮ViewController2,以及一个UIBarButtonItem模态呈现的按钮ViewController2.ViewController2有另一个UIWebView在"推"时工作但在"提出"时不工作.
双方ViewController并ViewController2装载有:
- (void)viewDidLoad {
[super viewDidLoad];
[self.webView loadHTMLString:@"<input type=\"file\" accept=\"image/*;capture=camera\">" baseURL:nil];
}
Run Code Online (Sandbox Code Playgroud)
当尝试使用模态UIWebViewXcode在控制台中打印以下内容并解除应用模式:
Warning: Attempt to present <UIImagePickerController: 0x150ab800> on <ViewController2: 0x14623580> whose view is not in the window hierarchy!
Run Code Online (Sandbox Code Playgroud)
我目前的理论是,在改变UIActionSheet到UIAlertController有可能产生这种情况,但它是非常难以证明.为了以防万一,我将与Apple一起打开雷达.
有人找到了相同的情况和一些解决方法吗?
我从相机获取UIimages并将它们分配给UIImageViews进行显示.当我这样做时,相机给我一个1200 x 1600像素的图像,然后我分配给我的应用程序中的UIImageView.在此条件下,图像在图像视图中按预期显示.但是,当我在将其分配给UIImageView之前尝试调整检索到的UIImage时,图像正在按预期调整大小但是在某处(在RESIZING代码中?)我的UIImage正在进行ROTATED ...结果,当我将调整大小的UIImage分配给UIImageView时,图像旋转90度并在宽高比(1200 x 1600像素)不变的情况下显示为拉伸...
我正在使用它来从相机获取UIImage:
- (void) imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
myImg = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
myResizedImg = [self resizeImage:myImg width:400 height:533];
[myImageView setImage:myResizedImg];
}
Run Code Online (Sandbox Code Playgroud)
我用它来调整它的大小:
-(UIImage *)resizeImage:(UIImage *)anImage width:(int)width height:(int)height
{
CGImageRef imageRef = [anImage CGImage];
CGImageAlphaInfo alphaInfo = CGImageGetAlphaInfo(imageRef);
if (alphaInfo == kCGImageAlphaNone)
alphaInfo = kCGImageAlphaNoneSkipLast;
CGContextRef bitmap = CGBitmapContextCreate(NULL, width, height, CGImageGetBitsPerComponent(imageRef), 4 * width, CGImageGetColorSpace(imageRef), alphaInfo);
CGContextDrawImage(bitmap, CGRectMake(0, 0, width, height), imageRef);
CGImageRef ref = CGBitmapContextCreateImage(bitmap);
UIImage *result = [UIImage imageWithCGImage:ref];
CGContextRelease(bitmap);
CGImageRelease(ref);
return result;
} …Run Code Online (Sandbox Code Playgroud)