开发者

How to make a registration page in an iPhone app?

I need a re开发者_如何学运维gistration page in my application which should appear only at the first launch of the application.


Look into:

  • NSUserDefaults (for saving and loading the registered info) - https://developer.apple.com/library/ios/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/Reference/Reference.html
  • Modal view controllers (for showing the page) -- http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/ModalViewControllers/ModalViewControllers.html

Use NSUserDefaults to save the registered info, and at startup, check if that information exists. If it doesn't, show the registration controller and save the info. That way it will only appear once.

A kind soul might do a lot of guesswork about your set up and write a clearer answer, or you could update your question telling us how you have tried to implement this yourself, and how you failed doing so because of [insert reason], and how you would love some hints on that.


Use NSUserDefaults in the viewDidLoad method of my main screen. So every time the app starts and the main screen loads, it checks if its the user's first time.

This is how I do it in my app:

 - (void)viewDidLoad {
 BOOL tempBOOL = [[NSUserDefaults standardUserDefaults] boolForKey:@"hasSeenOpeningAlert"];
      if (!tempBOOL) {
             UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome To My App" message:@"This app will ... First you need to ..." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
             [alert show];
             [alert release];
         }
      [super viewDidLoad];
}

and then:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
        Edit *editViewController = [[[Edit alloc] initWithNibName:@"Edit" bundle:nil]retain];
        [self.navigationController presentModalViewController:editViewController animated:YES];
        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasSeenOpeningAlert"];
        [[NSUserDefaults standardUserDefaults] synchronize];
        [editViewController release];
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜