- (void)viewDidLoad {
[super viewDidLoad];
+
self.navigationItem.title = @"Accounts";
self.navigationItem.leftBarButtonItem = self.editButtonItem;
UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addButtonPressed:)];
self.navigationItem.rightBarButtonItem = addButton;
- [addButton release];
-
- if ([[OpenStackAccount accounts] count] == 0) {
- // if there are no accounts, go straight to the add account screen on launch
- ProvidersViewController *vc = [[ProvidersViewController alloc] initWithNibName:@"ProvidersViewController" bundle:nil];
- vc.rootViewController = self;
- if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
- vc.modalPresentationStyle = UIModalPresentationFormSheet;
- }
- [self presentModalViewControllerWithNavigation:vc animated:NO];
- [vc release];
-
- } else if ([[OpenStackAccount accounts] count] == 1 && UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad) {
- // if there's only one account, go to its home screen
- // NOTE: not doing this on iPad because it screws up the split view controller.
- // TODO: make this work well with split view on iPad
- AccountHomeViewController *vc = [[AccountHomeViewController alloc] initWithNibName:@"AccountHomeViewController" bundle:nil];
- vc.account = [[OpenStackAccount accounts] objectAtIndex:0];
- vc.rootViewController = self;
- vc.rootViewIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
- [self.navigationController pushViewController:vc animated:NO];
- [vc release];
- }
-
+ [addButton release];
}
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController presentPrimaryViewController:vc];
[vc release];
}
+
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
+
+ if (!viewHasAppearedBefore) {
+ if ([[OpenStackAccount accounts] count] == 0) {
+ // if there are no accounts, go straight to the add account screen on launch
+ ProvidersViewController *vc = [[ProvidersViewController alloc] initWithNibName:@"ProvidersViewController" bundle:nil];
+ vc.rootViewController = self;
+ if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
+ vc.modalPresentationStyle = UIModalPresentationFormSheet;
+ }
+ [self presentModalViewControllerWithNavigation:vc];
+ [vc release];
+ } else if (([[OpenStackAccount accounts] count] == 1) && (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPad)) {
+ // if there's only one account, go to its home screen
+ // NOTE: not doing this on iPad because it screws up the split view controller.
+ // TODO: make this work well with split view on iPad
+ AccountHomeViewController *vc = [[AccountHomeViewController alloc] initWithNibName:@"AccountHomeViewController" bundle:nil];
+ vc.account = [[OpenStackAccount accounts] objectAtIndex:0];
+ vc.rootViewController = self;
+ vc.rootViewIndexPath = [NSIndexPath indexPathForRow:0 inSection:0];
+ [self.navigationController pushViewController:vc animated:NO];
+ [vc release];
+ }
+ viewHasAppearedBefore = YES;
+ }
}
/*