繁体   English   中英

如何以编程方式拍摄iPhone主屏幕快照?

[英]How to take a snapshot of iPhone Home Screen programmatically?

当用户点击我的应用程序图标时,我想在我的应用程序启动前拍摄iPhone主屏幕的快照,这与iOS4系统将应用程序置于后台模式之前的操作非常相似。 (我也想知道我的应用程序图标的确切中心XY位置。)

可能吗?

以下代码无效。 到那时,didFinishLaunchingWithOptions被称为主屏幕已经消失了。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    UIGraphicsBeginImageContext(self.window.frame.size);
    [self.window.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil); // for debugging purpose
}

很抱歉成为坏消息的承担者,但是看来这确实是一个隐私问题。

互联网世界中的许多Blog等都谈论了这一点,并且都摇了摇头“ NO”。

抱歉,但这是我们目前无法使用iphone进行的任务。

暂无
暂无

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

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