Objective-c: Visualizzare un UIAlertView al primo avvio dell’applicazione
Per visualizzare un UIAlertView al primo avvio di una app, potete utilizzare il seguente codice. Utilizziamo un NSUserDefaults per memorizzare un BOOL che conterrĂ YES dopo il primo avvio.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
-(void) showFirstRunAlerts { BOOL ranBefore = [[NSUserDefaults standardUserDefaults] boolForKey:@"RanBefore"]; if (!ranBefore) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Titolo Messaggio." message:@"Messaggio." delegate:self cancelButtonTitle:@"Grazie!" otherButtonTitles:nil]; [alert show]; [alert release]; [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"RanBefore"]; [[NSUserDefaults standardUserDefaults] synchronize]; } } |
enjoy!