- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *baseImage = [info objectForKey:UIImagePickerControllerOriginalImage];
if (baseImage == nil) return;
compositeImage = [self addOverlayToBaseImage:baseImage];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
NSDate* date = [NSDate date];
NSDateFormatter* formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat:@"yyyyMMddHHMMSS"];
NSString* str = [formatter stringFromDate:date];
//给照片按拍摄时间命名
NSString *uniquePath=[[paths objectAtIndex:0] stringByAppendingPathComponent:[NSString stringWithFormat:@"%@",str]];
BOOL result=[UIImagePNGRepresentation(compositeImage)writeToFile: uniquePath atomically:YES];
if (result) {
NSLog(@"success");
}
}
NSString *DocumentsDirectory = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"XXX.db"]; NSFileManager *fileManager = [[NSFileManager alloc] init]; if (![fileManager fileExistsAtPath:DocumentsDirectory]) { NSString *newFile = [[NSBundle mainBundle] pathForResource:@"XXX.db" ofType:nil]; [fileManager copyItemAtPath:newFile toPath:DocumentsDirectory error:nil]; } [fileManager release];