ios 9 - xcode 7 - SFSafariViewController - 图片上传 - 相机黑屏 [英] ios 9 - xcode 7 - SFSafariViewController - Image Upload - Camera Black Screen

查看:16
本文介绍了ios 9 - xcode 7 - SFSafariViewController - 图片上传 - 相机黑屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SFSafariViewController,遇到了以下问题:用户看到一个上传图像按钮,当点击设备正确显示多个选项,其中之一是相机.当用户选择相机时,它会加载相机但屏幕是黑色的,并且操作按钮是灰色的.但是,如果用户选择库,则选择的图像会正确上传.

我确实验证了该应用已开启相机权限.

我尝试实施在

但是,我的两分钱是:

  1. 考虑改用 UIWebview 或 WKWebview.您说您的网站是移动友好的,那么您可以考虑简单地将 UIWebview 拖到您的情节提要中并将其设置为指向您的网站.这里是一个很好的 UIWebviews 教程.另一个更明显的选择是使用 WKWebview.但是,在您的更新中,您已经指出您已经这样做了,因此我不会将您链接到任何教程.

否则,您目前无能为力,除了通过他们的 Bug Reporter<向 Apple 提交另一个雷达/a>.最后,您可以提交技术支持票,但我不会浪费任何一个,因为您每个会员年只有 2 个.

希望对你有帮助,朱利安

I'm working with SFSafariViewController, and ran into the following issue: The user is presented with an upload image button, when clicked the device properly displays multiple options, one of which is the camera. When the user selects the camera, it loads the camera but the screen is black, and the action button is greyed out. However if the user selects library, the selected image is properly uploaded.

I did verify that the app has camera permissions turned on.

I tried implementing the fixes found here and here, but to no avail.

Anyone else encounter this issue?

Code:

import UIKit
import SafariServices

class ViewController: UIViewController, SFSafariViewControllerDelegate
{
    private var urlString:String = "https://example.com"

    override func viewDidLoad()
    {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

    override func viewDidAppear(animated: Bool)
    {
        super.viewDidAppear(animated)

        let svc = SFSafariViewController(URL: NSURL(string: self.urlString)!)

        svc.delegate = self

        self.presentViewController(svc, animated: true, completion: nil)
    }

    func safariViewControllerDidFinish(controller: SFSafariViewController) {
        super.dismissViewControllerAnimated(true, completion: nil)
    }

    override func didReceiveMemoryWarning()
    {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

-----Update #1-----

After resetting privacy settings and trying to upload image directly from camera, I am not getting "SafariViewService Would Like to Access The Camera, which I think may be the problem. Because after I accept, the screen is still black, I'm wondering why it's not saying my app name like "FooBar" Would Like Access... Perhaps this misalignment is why the camera screen is black. Just not sure how to change it.

-----Update #2-----

This appears to be a SFSafariViewController issue, as I implemented WKWebView and the camera works fine.

解决方案

Edit iOS 11.3: Thank you to Rihards for commenting and pointing out this has been fixed.

This is apparently a known bug with the SFSafariViewController (I have submitted a radar which got closed). I faced the same issue that our mobile website was unable to get anything from the device, not the camera for a taken picture nor pictures from the camera roll. This was persisting in Safari and in SFSafariViewController, so we ended up simply redoing the complete upload process via native VC and Parse. However, I got a few suggestions from the Technical Support before doing all this and they told me to try the following:

  1. Check with a second device. Sometimes this could be a bug only happening on one device due to a mistake in the permissions. Checking with the second device should exclude the option that something went wrong at the installation
  2. Check the App's permissions in Settings. They told me that sometimes the blank screen came up if the User declined permission to use the camera. To check if this is the case, open settings, scroll down to the bottom and select your app. here you should see an ON/OFF toggle, which should both point to on. As seen in the screenshot below.

However, my two cents would be:

  1. Consider using a UIWebview or the WKWebview instead. You said that your site is mobile friendly, then you could consider simply dragging a UIWebview into your storyboard and setting it up to point to your site. Here is a good tutorial on UIWebviews. The other, more obvious alternative would be to use WKWebview. In your update, you have however already pointed out that you have done this, so I will not link you to any tutorials.

Otherwise there's not much you can do as of right now, besides of filing another radar to Apple with their Bug Reporter. Lastly, you could submit a ticket for Tech support, however I wouldn't waste any of those as you only have 2 per membership year.

Hope that helps, Julian

这篇关于ios 9 - xcode 7 - SFSafariViewController - 图片上传 - 相机黑屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆