简体   繁体   English

iPhone UIGetScreenImage的代码示例

[英]Code example for iPhone UIGetScreenImage

I've seen a number of posts on UIGetScreenImage, however, not a complete working (short) code example. 我在UIGetScreenImage上看过很多帖子,但是,这不是一个完整的工作(简短)代码示例。

If anyone has a code example, from the prototype definition to an actual call, that would be greatly appreciated. 如果有人有代码示例,从原型定义到实际调用,那将非常感激。

CGImageRef UIGetScreenImage(void);

....

    CGImageRef screen = UIGetScreenImage();
    UIImage* screenImage = [UIImage imageWithCGImage:screen];
    CGImageRelease(screen); // you need to call this. 
                           // UIGetScreenImage violates the CF memory management rules.
    // Use screenImage as you like.

Recently I needed to integrate taking screenshots into my iOS app. 最近我需要将屏幕截图集成到我的iOS应用程序中。 This question comes up pretty high in the search list on StackOverflow. 这个问题在StackOverflow的搜索列表中非常高。 However, since the initial public release of this method, Apple has made UIGetScreenImage private and any call to it will get your app rejected. 但是,自从此方法首次公开发布以来,Apple已将UIGetScreenImage私有,并且对其进行任何调用都会导致您的应用被拒绝。

Apple made this post on their official forum regarding replacing calls to UIGetScreenImage . 苹果发这个帖子在自己的官方论坛上关于更换呼叫UIGetScreenImage

Programmatic screenshots are no longer as simple as they use to be and there are now different ways to take a screenshot depending on the type of image that needs to be acquired. 程序化截图不再像过去那样简单,现在有不同的方法可以根据需要获取的图像类型来截取屏幕截图。

The above Apple forum post explains how to take an image in each context. 上面的Apple论坛帖子解释了如何在每个上下文中拍摄图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM