2010-01-04 4 views
2

J'essaie de trouver un moyen que mon programme affichera une "configuration" -view, lorsque vous démarrez l'application pour la première fois, mais cela ne fonctionne pas.Comment obtenir une vue "première fois ouverte" pour mon application?

Voici ma tentative. L'appdelegate devrait chercher, si le programme s'ouvre la première fois (abfrage = false) et ouvrir une autre vue.

#import "TweetButtonAppDelegate.h" 
#import "TweetButtonViewController.h" 
#import "BenutzerdatenViewController.h" 

@implementation TweetButtonAppDelegate 

@synthesize window; 
@synthesize viewController; 
@synthesize abfrage; 


- (void)applicationDidFinishLaunching:(UIApplication *)application { 
    abfrage = FALSE; 
if (abfrage == TRUE) { 
    [window addSubview:viewController.view]; 
    [window makeKeyAndVisible]; 
} else { 
    BenutzerdatenViewController *Benutzerdaten = [[BenutzerdatenViewController alloc] initWithNibName:nil bundle:nil]; 
    [Benutzerdaten release];} 
} 
(...) 

J'ai essayé de construire un si-requête dans la appdelegate, mais toujours quand « Abfrage » est faux, le programme charge juste une vue blanc.

Répondre

0

je une solution de création, qui peut être réglée dans le applicationDidFinishLaunching du AppDelegate:

- (void)applicationDidFinishLaunching:(UIApplication *)application { 
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
    NSString *firsttime = [defaults stringForKey:@"firsttime"]; 
    if (firsttime == nil) { 

     TheOtherViewController *Other = [[TheOtherViewController alloc] initWithNibName:nil bundle:nil]; 
     Other.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
     [window addSubview: Other.view];   

     [defaults setObject:@"lasttime" forKey:@"firsttime"]; 
    } else { [window addSubview:viewController.view]; 
     [window makeKeyAndVisible]; 
    } 
} 
0

Essayez ce qui est mis en œuvre dans le contrôleur de vue « niveau »:

- (void)viewDidAppear:(BOOL)animated { 
    [flasher setSettingsFromModel:self.settingsModel]; 
    if (self.settingsModel.warningAccepted == NO) { 
     [self showWarning]; 
     [flasher setFlashingEnabled:NO]; 
    } else 
     [flasher setFlashingEnabled:YES]; 
    [super viewDidAppear:animated]; 
} 

... 

- (void)modalViewControllerDidFinish:(UIViewController *)controller { 
     if (self.settingsModel.warningAccepted == YES) 
      [flasher setFlashingEnabled:YES]; 
     [self dismissModalViewControllerAnimated:YES]; 
} 

... 

- (void)showWarning { 
     WarningViewController *controller = [[WarningViewController alloc] 
         initWithNibName:@"WarningView" bundle:nil]; 
     controller.delegate = self; 
     controller.settingsModel = settingsModel; 
      controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
     [self presentModalViewController:controller animated:YES]; 
     [controller release]; 
} 

Essentiellement, je pense que vous voulez faire en viewDidAppear dans votre contrôleur principal de la vue. Au moins c'est comme ça que je l'ai fait.

+0

Je ne pas savoir pourquoi, mais mon ViewController doens't charger la nouvelle vue, si je l'ai mis en ViewDidAppear ou viewDidLoad - Je sais que mon code est correct, parce que quand je n'ai que le code essentiel pour un UIAction, il charge la nouvelle vue en appuyant sur un bouton. – Flocked

0

Le problème est que vous initialisez une nouvelle BenutzerdatenViewController, mais ne pas ajouter à la fenêtre.

Vous devez ajouter qu'après l'initialisation:

[window addSubview: Benutzerdaten.view]; 
[window makeKeyAndVisible]; 
Questions connexes