问题
I need to capture a part of a big UIView which is inside a UIScrollView.
I was using the CALayer's method renderInContext:
since more than 2 years.
Even if the method failed to render special objects (like MapView) 99% of the time it was perfect and fast enough for my needs.
But with iOS7 the rendering of many components is totally buggy (and became worst with the last versions of iOS 7.1).
So I wanted to use the new methods that seems to be more dedicated to that like the UIView's drawViewHierarchyInRect:afterScreenUpdates
.
Unfortunately I can't manage to make it work on real devices, it's rendering black images (empty contents). It's working like a charm only on the simulator (retina or not) and -- I think -- on non retina real devices (I've tested on the first gen iPad mini)... To sum up:
- iPad Simulator working
- iPad retina Simulator working
- iPad mini (1st gen) working
- iPad 3 and 4 gen NOT working
- iPad Air NOT working
Here you can find a simple Xcode project that is showing the issue.
Run it on the simulator and then on a real (retina) device to see the differences and the issue.
I've attached two screenshots at the end of this post showing that. Left images show the result with the renderInContext:
method, the right ones show the drawViewHierarchyInRect:afterScreenUpdates
method result.
I've scratched my head on it since too long now! I've even asked help through an Apple DTS which was rejected saying that sounds like an Apple bug and that I should filled a bug report (thing that I've already done for a long).
If you have any idea, comment, etc... I would be really grateful.
Thanks
来源:https://stackoverflow.com/questions/25432222/drawviewhierarchyinrectafterscreenupdates-and-renderincontext-dont-work-ot