Only the major iPhone frameworks have been covered in this book. Dozens of smaller, proprietary frameworks exist on the iPhone waiting to be explored. Through a little bit of hacking, some of these smaller frameworks have proven themselves useful for one-off needs. A number of other interesting recipes have also been concocted for performing tasks such as initiating a phone call or setting the iPhone’s vibrator. This chapter covers some of the hacks and recipes we couldn’t fit anywhere else in the book.
UIApplication class sports
a method named
that can be used to make a screenshot on the iPhone. The method causes a
file named /tmp/foo_0.png to be
written to disk.
To dump the screen contents from within your application, make
sure to call the
method from your
[ self _dumpScreenContents: nil ];
You’ll need to have at least a main window with a content view
created to take a screenshot. Every call to
_dumpScreenContents causes the file to be
written to the same location, /tmp/foo_0.png, so be sure to move it out of
the way if you’re taking multiple screenshots.
This example takes a snapshot of the screen from the command line, allowing the user to log in via SSH and capture the currently running application. Only iPhone firmware versions 1.x are able to take screenshots from the command line. Versions 2.x and newer can ...