【问题标题】:iPhone ScreenshotsiPhone 截图
【发布时间】:2010-07-27 17:28:52
【问题描述】:

我一直在使用 UIGetScreenImage() 来获取 UIImagePickerController 的屏幕截图。基本上我使用相机叠加层,然后当我截取屏幕截图时,我有相机预览显示的图像以及我的叠加层,这正是我需要的。

现在 UIGetScreenImage() 已被禁止,我无法找到方法来做到这一点。它只是为相机显示黑色。

编辑:我所有的其他视图都显示得很好,只是不是实际的相机预览。有什么想法吗??!?!?

这是我目前正在使用的代码。


UIGraphicsBeginImageContext(picker.view.bounds.size);
[picker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
CGContextDrawImage(context, bounds, camView.CGImage);
UIImage* screenImage = UIGraphicsGetImageFromCurrentImageContext();
UIImageWriteToSavedPhotosAlbum(screenImage, nil, nil, nil); 
UIGraphicsEndImageContext();

任何想法如何获得叠加层 + 相机图像?

谢谢!

【问题讨论】:

    标签: iphone camera screenshot uipickerviewcontroller


    【解决方案1】:

    这与你的略有不同。

    CGRect screenRect = [[UIScreen mainScreen] bounds];
            UIGraphicsBeginImageContext(screenRect.size);
            [self.layer renderInContext:UIGraphicsGetCurrentContext()];
            UIImage *sShot = UIGraphicsGetImageFromCurrentImageContext();
            UIGraphicsEndImageContext();
            UIImageWriteToSavedPhotosAlbum (sShot, nil, nil, nil);
    

    这行得通吗?

    如果没有,您可能想尝试通过iphonedevsdk.com 询问,因为他们专注于 iPhone 的所有方面。

    【讨论】:

    • 谢谢,我试了一下,结果相同(UIImagePickerController 下面的视图。我也会在那里发一个问题,看看是否有人以前做过。
    【解决方案2】:

    让他们拍照。然后将你的图片叠加在上面。

    Create a UIImage from two other UIImages on the iPhone

    【讨论】:

    • 谢谢,不过这有点过分了。只需要从视图本身获取图像。不过我可能不得不走那条路。
    • 我认为删除 API 的原因是因为在没有用户干预的情况下获取屏幕截图违反了安全性。我认为有很多方法可以这样侵犯隐私。不确定这是否正确,但除此之外,我无法很好地解释为什么它被删除而别无选择。
    • 感谢您的解释!我确信有办法做到这一点并遵守准则,只是烦人而已!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多