From 7db406cdb6003cb8aacba0cdb6ba29a8b0ee534c Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Fri, 28 Sep 2012 16:23:15 +0200 Subject: [PATCH] Reset contact selection mode after edit Fix image zoom --- Classes/ContactDetailsViewController.m | 3 +++ Classes/ContactsTableViewController.m | 2 +- Classes/ImageViewController.h | 2 +- Classes/ImageViewController.m | 15 ++++++++++----- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Classes/ContactDetailsViewController.m b/Classes/ContactDetailsViewController.m index d32d50450..e160786c1 100644 --- a/Classes/ContactDetailsViewController.m +++ b/Classes/ContactDetailsViewController.m @@ -299,6 +299,9 @@ static UICompositeViewDescription *compositeDescription = nil; } - (IBAction)onBackClick:(id)event { + if([ContactSelection getSelectionMode] == ContactSelectionModeEdit) { + [ContactSelection setSelectionMode:ContactSelectionModeNone]; + } [[PhoneMainView instance] popCurrentView]; } diff --git a/Classes/ContactsTableViewController.m b/Classes/ContactsTableViewController.m index a26faef6a..eec7d4ae0 100644 --- a/Classes/ContactsTableViewController.m +++ b/Classes/ContactsTableViewController.m @@ -217,7 +217,7 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf // Go to Contact details view ContactDetailsViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactDetailsViewController compositeViewDescription] push:TRUE], ContactDetailsViewController); if(controller != nil) { - if([ContactSelection getAddAddress] == nil) { + if([ContactSelection getSelectionMode] != ContactSelectionModeEdit) { [controller setContact:lPerson]; } else { [controller editContact:lPerson address:[ContactSelection getAddAddress]]; diff --git a/Classes/ImageViewController.h b/Classes/ImageViewController.h index 080e1b146..69e04bb27 100644 --- a/Classes/ImageViewController.h +++ b/Classes/ImageViewController.h @@ -22,7 +22,7 @@ #import "UICompositeViewController.h" @interface UIImageScrollView : UIScrollView - + @property (nonatomic, retain) UIImage *image; @property (readonly) IBOutlet UIImageView *imageView; diff --git a/Classes/ImageViewController.m b/Classes/ImageViewController.m index 8b2853f91..d577f5b8c 100644 --- a/Classes/ImageViewController.m +++ b/Classes/ImageViewController.m @@ -30,7 +30,7 @@ - (void)initUIImageScrollView { imageView = [[UIImageView alloc] init]; - self.delegate = self; + self.delegate = self; [self addSubview:imageView]; } @@ -70,11 +70,11 @@ - (void)layoutSubviews { [super layoutSubviews]; - // center the image as it becomes smaller than the size of the screen CGSize boundsSize = self.bounds.size; CGRect frameToCenter = imageView.frame; + // center horizontally if (frameToCenter.size.width < boundsSize.width) frameToCenter.origin.x = (boundsSize.width - frameToCenter.size.width) / 2; @@ -87,6 +87,7 @@ else frameToCenter.origin.y = 0; + imageView.frame = frameToCenter; } @@ -94,10 +95,14 @@ #pragma mark - Property Functions - (void)setImage:(UIImage *)aimage { + self.minimumZoomScale = 0; + self.zoomScale = 1; + + CGRect rect = CGRectMake(0, 0, aimage.size.width, aimage.size.height); imageView.image = aimage; - imageView.frame = CGRectMake(0, 0, aimage.size.width, aimage.size.height); - self.contentSize = aimage.size; - [self zoomToRect:imageView.bounds animated:FALSE]; + imageView.frame = rect; + self.contentSize = rect.size; + [self zoomToRect:rect animated:FALSE]; self.minimumZoomScale = self.zoomScale; }