- January 2006 (1)
- January 2007 (1)
- July 2007 (8)
- August 2007 (3)
- September 2007 (3)
- October 2007 (2)
- November 2007 (3)
- January 2008 (5)
- February 2008 (4)
- March 2008 (1)
- April 2008 (5)
- June 2008 (3)
- July 2008 (2)
- August 2008 (1)
- September 2008 (6)
- November 2008 (3)
- December 2008 (1)
- January 2009 (4)
- March 2009 (1)
- April 2009 (14)
- May 2009 (9)
- June 2009 (7)
- July 2009 (6)
- August 2009 (4)
- September 2009 (4)
- October 2009 (2)
- November 2009 (23)
- December 2009 (23)
- January 2010 (4)
- February 2010 (3)
- March 2010 (2)
- May 2010 (3)
- July 2010 (4)
code
Changing Background Color and Section Header Text Color in a Grouped-style UITableView
Tue, 08/25/2009 - 19:10 | by KrisWhile working on an iPhone application, I decided I wanted to change the colors of the background and section headers of a UITableView with the UITableViewStyleGrouped style. It took a lot more work than I expected, so I'm sharing what I learned with anyone else who needs to do this.
Adding a Custom View to an NSStatusItem
Tue, 07/07/2009 - 06:48 | by KrisMy Menubar Countdown application uses an NSStatusItem to display itself in the menu bar. I recently had to add a custom view to that status item, and thought I'd share what I learned about the process here.
Saving a View as a Photo in an iPhone App
Fri, 01/16/2009 - 01:52 | by KrisFor an iPhone app that I'm working on, I want to be able to save the screen image to the Photos album. My first attempt at this was complicated: I created a color space, a bitmap context, a CGImage, and finally a UIImage, copying and pasting most of the code from the Quartz 2D Programming Guide. Unfortunately, it didn't work; I kept getting BAD_ACCESS signals when I called UIImageWriteToSavedPhotosAlbum(), even though it looked to me like everything was correct.
After Googling for a bit for known issues with UIImageWriteToSavedPhotosAlbum, I ran across a far easier solution to the problem. Here are the methods I ended up with:
// Create an image for the view and save it to the Photos library
- (void)savePhotoOfView:(UIView *)view
{
UIGraphicsBeginImageContext(view.bounds.size);
[view drawRect:view.bounds];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(image,
self,
@selector(savedPhotoImage:didFinishSavingWithError:contextInfo:),
NULL);
}
// Called by UIImageWriteToSavedPhotosAlbum() when it completes
- (void) savedPhotoImage:(UIImage *)image
didFinishSavingWithError:(NSError *)error
contextInfo:(void *)contextInfo
{
NSString *message = @"This image has been saved to your Photos album";
if (error) {
message = [error localizedDescription];
}
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:message
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
[alert release];
}
These just call the view's drawRect method to create an image, save the image to the Photos library, and then pop up an alert box to let the user know what happened.
Recent comments
5 weeks 5 days ago
6 weeks 2 days ago
7 weeks 6 days ago
8 weeks 3 days ago
8 weeks 3 days ago
9 weeks 1 day ago
11 weeks 4 days ago
12 weeks 2 days ago
15 weeks 1 day ago
17 weeks 4 days ago