#pragma mark - UIImagePickerControllerDelegate - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{ //NSLog(@"%@",info); UIImage *choosedImage = [[UIImage alloc]init]; if ([picker allowsEditing]) { choosedImage = [info objectForKey:UIImagePickerControllerEditedImage]; }else{ choosedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; } [Photo scaleImage:choosedImage toWidth:100 toHeight:100]; headImageView.image = choosedImage; NSData *data; NSString *imagePath; NSString *path = [NSSearchPathForDirectoriesInDomains(NSDocumentationDirectory, NSUserDomainMask, YES) objectAtIndex:0]; if (UIImagePNGRepresentation(choosedImage) == nil) { data = UIImageJPEGRepresentation(choosedImage, 1); imagePath = [path stringByAppendingString:@"/headImage.jpg"]; }else{ data = UIImagePNGRepresentation(choosedImage); imagePath = [path stringByAppendingString:@"/headImage.png"]; } //NSLog(@"[path = %@]",headImagePath); [data writeToFile:imagePath atomically:YES]; [self.navigationController dismissViewControllerAnimated:YES completion:nil]; }