iPhone Dev Tip #1: Taking a Screenshot
Since this is what I do for a living, I thought I'd start posting some tips for iPhone development. Most of the time, these will be cross-posted (or asked by me) on http://www.stackoverflow.com since I participate in the Q/A there. The site is a fantastic resource -- check it out.
Without further adieu, tip #1. This is a pretty important thing to do in a lot of cases and not easily understood by looking at the documentation in the SDK. Funnily enough, it can be boiled down to a few short lines:
UIGraphicsBeginImageContext(self.view.frame.size); //size of your screenshot //render the view you want in the new image context [[self.view layer] renderInContext:UIGraphicsGetCurrentContext()]; UIImage* image = UIGraphicsGetImageFromCurrentImageContext(); [image retain]; //this is an unretained UIImage, so let's save it UIGraphicsEndImageContext();
That's it. There's a lot more to be said about CGContexts and the like, but a lot of the difficulty of working with these are simplified with the UIGraphics*() functions. Search for them in the XCode documentation.
Tune in next time for another helpful tip!
Bloggin’ Stuff
Sup.
So, things have been pretty busy around here, which generally means no blogging or site updates. While that won't change in the future, it is worth dropping a few things of note:
- SliceHost.com is totally completely 100% awesome. I have been with them for a while now and have had no downtime, no problems with CPU and Memory hogging from other VHosts (because there aren't any!) and the price is extremely reasonable for the service that you get. I am running apache2, git, svn, irc, ftp, mail, mysql, and ssh servers without any problems whatsoever. Additionally, for LatestChatty.app that I have majorly contributed to I run an API server that takes considerable CPU which continues to chug along on every request I make of it. It's pretty awesome.
- iPhone Development is pretty sweet. While I've been working on a lot of things for work, I still have found a little time to work on LatestChatty.app, which I'll write a blog post on eventually. It was on the Staff Favorites section of the appstore! I'm pretty proud of the work I've done in making the application stable. I can use it on the train without any significant problems... however the app has some issues with lots of data in UIWebViews which will be rectified shortly through various means.