Advertisement

devsugar: Accessing an iPhone camera capture session

With the imminent demise of UIGetScreenImage, a number of readers have asked me how they can use the newer AVFoundation approach to access screen data in their iPhone applications. I went ahead and built some sample code that, when I'm finished messing with it, will be part of chapter 7 of my revised cookbook. I have uploaded the current version to github. It consists of a simple helper class that allows you to start and stop a capture session.

You can request an image from this helper (namely, the last captured image from the buffer), which in this example is loaded into a central image view at the end-user's request. You can also ask it for a view with an embedded preview, using the current session. The example project adds that preview to the navigation bar.

I threw this example together pretty quickly, and as always, I welcome suggestions and improvements.