diff options
author | Mikkel Krautz <mikkel@krautz.dk> | 2010-09-01 02:27:08 +0400 |
---|---|---|
committer | Mikkel Krautz <mikkel@krautz.dk> | 2010-09-01 02:27:08 +0400 |
commit | 645e229ddc434845e2c7cf26a47745903b30db59 (patch) | |
tree | d7e9228c4f3d0fe656effcf5ed4ed55eace23877 | |
parent | 80246be013fb59f392d0a32570e4266adc05cd4a (diff) |
Fix IdentityViewController display.
-rw-r--r-- | Source/Classes/Identity.h | 10 | ||||
-rw-r--r-- | Source/Classes/IdentityViewController.h | 3 | ||||
-rw-r--r-- | Source/Classes/IdentityViewController.m | 34 |
3 files changed, 28 insertions, 19 deletions
diff --git a/Source/Classes/Identity.h b/Source/Classes/Identity.h index 4234632..d73f077 100644 --- a/Source/Classes/Identity.h +++ b/Source/Classes/Identity.h @@ -29,11 +29,11 @@ */ @interface Identity : NSObject { - NSInteger _pkey; - NSData *_persistent; - NSString *_userName; - NSString *_fullName; - NSString *_emailAddress; + NSInteger _pkey; + NSData *_persistent; + NSString *_userName; + NSString *_fullName; + NSString *_emailAddress; } @property (assign) NSInteger primaryKey; diff --git a/Source/Classes/IdentityViewController.h b/Source/Classes/IdentityViewController.h index e19642f..a5cd4bf 100644 --- a/Source/Classes/IdentityViewController.h +++ b/Source/Classes/IdentityViewController.h @@ -31,8 +31,7 @@ @interface IdentityViewController : UITableViewController { NSMutableArray *_identities; NSMutableArray *_certificateItems; - - NSUInteger _currentView; + NSInteger _currentView; } - (id) init; diff --git a/Source/Classes/IdentityViewController.m b/Source/Classes/IdentityViewController.m index 405ab7c..871adce 100644 --- a/Source/Classes/IdentityViewController.m +++ b/Source/Classes/IdentityViewController.m @@ -33,16 +33,17 @@ #import "Database.h" #import "Identity.h" -static NSUInteger IdentityViewControllerIdentityView = 0; -static NSUInteger IdentityViewControllerCertificateView = 1; +static NSInteger IdentityViewControllerIdentityView = 0; +static NSInteger IdentityViewControllerCertificateView = 1; @interface IdentityViewController (Private) -- (void) setCurrentView:(NSUInteger)currentView; +- (void) setCurrentView:(NSInteger)currentView; - (void) animateDeleteRowsCount:(NSUInteger)count withRowAnimation:(UITableViewRowAnimation)rowAnimation; - (void) animateInsertRowsCount:(NSUInteger)count withRowAnimation:(UITableViewRowAnimation)rowAnimation; - (void) deleteIdentityForRow:(NSUInteger)row; - (void) deleteCertificateForRow:(NSUInteger)row; - (void) fetchCertificates; +- (void) viewChanged:(UISegmentedControl *)segmentedControl; @end @implementation IdentityViewController @@ -55,6 +56,8 @@ static NSUInteger IdentityViewControllerCertificateView = 1; if (self == nil) return nil; + _currentView = -1; + return self; } @@ -84,6 +87,8 @@ static NSUInteger IdentityViewControllerCertificateView = 1; [flexSpace release]; [barSegmented release]; + + [self viewChanged:segmentedControl]; } - (void) viewWillDisappear:(BOOL)animated { @@ -95,13 +100,11 @@ static NSUInteger IdentityViewControllerCertificateView = 1; [self.navigationController setToolbarHidden:YES animated:NO]; } -- (void) setCurrentView:(NSUInteger)currentView { - // No change in view, the view just re-appeared. - if (currentView == _currentView) { - [self.tableView reloadData]; +- (void) setCurrentView:(NSInteger)currentView { + BOOL animate = (currentView != _currentView); // View changed to identity view - } else if (currentView == IdentityViewControllerIdentityView) { + if (currentView == IdentityViewControllerIdentityView) { self.navigationItem.title = @"Identities"; UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonClicked:)]; [self.navigationItem setRightBarButtonItem:addButton]; @@ -110,11 +113,13 @@ static NSUInteger IdentityViewControllerCertificateView = 1; NSUInteger deleteCount = [_certificateItems count]; [_certificateItems release]; _certificateItems = nil; - [self animateDeleteRowsCount:deleteCount withRowAnimation:UITableViewRowAnimationRight]; + if (animate) + [self animateDeleteRowsCount:deleteCount withRowAnimation:UITableViewRowAnimationRight]; _currentView = currentView; _identities = [[Database fetchAllIdentities] retain]; - [self animateInsertRowsCount:[_identities count] withRowAnimation:UITableViewRowAnimationLeft]; + if (animate) + [self animateInsertRowsCount:[_identities count] withRowAnimation:UITableViewRowAnimationLeft]; // View changed to certificate view } else if (currentView == IdentityViewControllerCertificateView) { @@ -124,12 +129,17 @@ static NSUInteger IdentityViewControllerCertificateView = 1; NSUInteger deleteCount = [_identities count]; [_identities release]; _identities = nil; - [self animateDeleteRowsCount:deleteCount withRowAnimation:UITableViewRowAnimationLeft]; + if (animate) + [self animateDeleteRowsCount:deleteCount withRowAnimation:UITableViewRowAnimationLeft]; _currentView = currentView; [self fetchCertificates]; - [self animateInsertRowsCount:[_certificateItems count] withRowAnimation:UITableViewRowAnimationRight]; + if (animate) + [self animateInsertRowsCount:[_certificateItems count] withRowAnimation:UITableViewRowAnimationRight]; } + + if (!animate) + [self.tableView reloadData]; } - (void) animateDeleteRowsCount:(NSUInteger)count withRowAnimation:(UITableViewRowAnimation)rowAnimation { |