contact: rotate photo when invalid rotation

This commit is contained in:
Gautier Pelloux-Prayer 2016-04-04 14:14:15 +02:00
parent f357fd0975
commit f6747e1ffc
4 changed files with 30 additions and 3 deletions

View file

@ -556,6 +556,15 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark ImagePickerDelegate
- (void)imagePickerDelegateImage:(UIImage *)image info:(NSDictionary *)info {
// When getting image from the camera, it may be 90° rotated due to orientation
// (image.imageOrientation = UIImageOrientationRight). Just rotate it to be face up.
if (image.imageOrientation != UIImageOrientationUp) {
UIGraphicsBeginImageContextWithOptions(image.size, false, image.scale);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
// Dismiss popover on iPad
if (IPAD) {
[VIEW(ImagePickerView).popoverController dismissPopoverAnimated:TRUE];

View file

@ -79,10 +79,10 @@
added = [_contact addEmail:value];
}
if (added && animated) {
if (added) {
NSUInteger count = [self getSectionData:section].count;
[tableview insertRowsAtIndexPaths:@[ [NSIndexPath indexPathForRow:count - 1 inSection:section] ]
withRowAnimation:UITableViewRowAnimationFade];
withRowAnimation:animated ? UITableViewRowAnimationFade : UITableViewRowAnimationNone];
}
}
@ -223,7 +223,7 @@
[self removeEmptyEntry:self.tableView section:section animated:NO];
// the section is empty -> remove titles
if ([[self getSectionData:section] count] == 0 && animated) {
if ([[self getSectionData:section] count] == 0) {
[self.tableView
reloadSections:[NSIndexSet indexSetWithIndex:section]
withRowAnimation:animated ? UITableViewRowAnimationFade : UITableViewRowAnimationNone];

View file

@ -310,6 +310,15 @@ static UICompositeViewDescription *compositeDescription = nil;
#pragma mark - Image picker delegate
- (void)imagePickerDelegateImage:(UIImage *)image info:(NSDictionary *)info {
// When getting image from the camera, it may be 90° rotated due to orientation
// (image.imageOrientation = UIImageOrientationRight). Just rotate it to be face up.
if (image.imageOrientation != UIImageOrientationUp) {
UIGraphicsBeginImageContextWithOptions(image.size, false, image.scale);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
// Dismiss popover on iPad
if (IPAD) {
[VIEW(ImagePickerView).popoverController dismissPopoverAnimated:TRUE];

View file

@ -99,6 +99,15 @@
#pragma mark - Image picker delegate
- (void)imagePickerDelegateImage:(UIImage *)image info:(NSDictionary *)info {
// When getting image from the camera, it may be 90° rotated due to orientation
// (image.imageOrientation = UIImageOrientationRight). Just rotate it to be face up.
if (image.imageOrientation != UIImageOrientationUp) {
UIGraphicsBeginImageContextWithOptions(image.size, false, image.scale);
[image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
// Dismiss popover on iPad
if (IPAD) {
[VIEW(ImagePickerView).popoverController dismissPopoverAnimated:TRUE];