使用presentationlayer的renderincontext屏幕捕获不工作 [英] Screen capture using renderincontext of presentationlayer not working

查看:220
本文介绍了使用presentationlayer的renderincontext屏幕捕获不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照说明<一个href=\"http://stackoverflow.com/questions/4498135/how-to-capture-iphone-screen-with-animating-uiimageview\">here拍摄动画时的截图(我想用一个动画标签记录的UIView捕捉到它作为视频)

I followed the instructions here to capture screenshots during animation (I am trying to record UIView with an animated label to capture it as video)

这是我的code在我的ViewController(的getFrame)屏幕捕获

here is my code for screen capture in my ViewController (getframe)

-(UIImage*) getCurrentFrame {
    UIGraphicsBeginImageContext(self.view.bounds.size);
CGContextRef mycontext =  UIGraphicsGetCurrentContext();
    [[[self.view layer] presentationLayer] renderInContext:mycontext]; 

    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    return image;
}

当我试图让屏幕截图的视频,我曾多次看到的只是起始帧 - 为我的线程(使用AVAssetwriter例子)抓住了移动截屏截屏以后没事。截屏将在while循环AVAssetWriterInput usingblock过程中调用。

when I try to make a video of the screenshots, I repeatedly see only the start frame - as my thread (using AVAssetwriter example) grabs subsequent screenshots nothing in the screengrab moves. the screengrab is called during AVAssetWriterInput usingblock in a while loop.

我的动画是一个标签上一个简单的核心动画 - 向下滚动的例子

My animation is a simple core animation on a label - scroll down example

mTextLabel.frame = CGRectMake(mTextLabel.frame.origin.x,
                             -100,
                             mTextLabel.frame.size.width,
                             mTextLabel.frame.size.height);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration: delay];
[UIView setAnimationTransition:UIViewAnimationTransitionNone
                       forView:mTextLabel cache:YES];
mTextLabel.frame = CGRectMake(mTextLabel.frame.origin.x,
                             240,
                             mTextLabel.frame.size.width,
                             mTextLabel.frame.size.height);
[UIView commitAnimations];

我试着用块动画animatewithDuration更换旧学校的动画,但得到相同的结果。

I tried replacing the old school animation with the block animation animatewithDuration but get the same results

有什么建议?
使用的是iOS 6和最新的X code(已导入Quartzcore正确)

Any suggestions? Using ios 6 and latest xcode (have imported Quartzcore correctly)

苹果开发中心的出头可能不抓获。

Apple dev center said that somethings might not be captured.

时的另一种选择阶段,计时器的动画和间歇性地抓住屏幕(将手code动画)?

Is another option to stage the animation with timers and intermittently grab screens (will have to handcode animations)?

推荐答案

编辑 - 万岁!苹果最终添加了这个 -

EDIT - Hooray ! Apple finally added this -

[view drawViewHierarchyInRect:self.view.bounds afterScreenUpdates:NO];

裹的开始和结束图形上下文调用!

wrap between Begin and End Graphics Context calls !

------------ pre iOS7 ---------------
从苹果公司的文档资料的CALayer <一个href=\"https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CALayer_class/Introduction/Introduction.html\"相对=nofollow>这里!
在renderInContext他们说清楚

------------ pre iOS7 --------------- From Apple's Documentation for CALayer here! In renderInContext they clearly say

重要:在OS X v10.5上实现这个方式不支持整个Core Animation的组合模型 QCCompositionLayer,CAOpenGLLayer和QTMovieLayer层不会呈现此外,层使用3D变换不能渲染,也不是指定backgroundFilters层,过滤器,compositingFilter或屏蔽值。OS X的未来版本可能会增加对这些渲染层和属性的支持。

"Important: The OS X v10.5 implementation of this method does not support the entire Core Animation composition model. QCCompositionLayer, CAOpenGLLayer, and QTMovieLayer layers are not rendered. Additionally, layers that use 3D transforms are not rendered, nor are layers that specify backgroundFilters, filters, compositingFilter, or a mask values. Future versions of OS X may add support for rendering these layers and properties."

对我来说,唯一的选择就是在时间t手动覆盖改造,使用服务器端的解决方案或C逐帧动画帧手$ C $。

The only option for me is to use server side solution OR handcode the animation frame by frame by manually overlaying the transformation at time t.

这篇关于使用presentationlayer的renderincontext屏幕捕获不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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