简体   繁体   English

UIGetScreenImage-专用API

[英]UIGetScreenImage - Private API

I was using UIGetScreenImage in my app, however, as everyone knows Apple is rejecting apps using private APIs. 但是,我在应用程序中使用的是UIGetScreenImage,因为大家都知道Apple拒绝使用私有API的应用程序。 I have researched alternate ways to do this with takepicture but you get different size images as well as the annoying snapshot sound. 我已经研究了使用拍照实现此目的的其他方法,但是您会得到不同大小的图像以及令人讨厌的快照声音。 Microsoft tag. Microsoft标签。 Quickmark and Redalaser all use the UIGetScreenImage (it's obvious) but I want to do this legally. Quickmark和Redalaser都使用UIGetScreenImage(很明显),但是我想合法地这样做。 Does anyone out there have any suggestions. 有没有人有任何建议。 Much appreciated. 非常感激。

This might work... I think that it was the answer to another SO question. 这可能行得通...我认为这是另一个SO问题的答案。

-(UIImage *)captureView:(UIView *)view {
    CGRect screenRect = [[UIScreen mainScreen] bounds];    
    UIGraphicsBeginImageContext(screenRect.size);
    CGContextRef ctx = UIGraphicsGetCurrentContext(); 
    [[UIColor blackColor] set]; 
    CGContextFillRect(ctx, screenRect);
    [view.layer renderInContext:ctx];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return newImage; 
}

UIGetScreenImage is currently Apple's recommended way of capturing the screen. 目前, UIGetScreenImage是Apple推荐的捕获屏幕的方法。 It's sort of a private method, but they've stated in the developer forums that using it is acceptable until they add a public-API equivalent. 这是一种私有方法,但他们在开发人员论坛中表示,除非添加等效的public-API,否则使用它是可以接受的。

Update: UIGetScreenImage is no longer allowed, as of iOS 4; 更新:从iOS 4开始,不再允许UIGetScreenImage I believe the approved way to take pictures is now using the AVFoundation framework. 我相信现在已批准的拍照方式是使用AVFoundation框架。

最好的(也是最慢的)方法是向Apple提出功能请求。

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

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