简体   繁体   中英

Automatically Load UIView from another UIView

I'm trying to build an iPhone app that allows users to register from their phone itself. At the first page (login form) I have a "register now" button that displays a Registration Form to do just that.

So the workflow now is:
1. User stars app, load form A
2. App detects that user is new, UIAlert to say that User needs to register
3. User has to click 'Register Now' to register (form B)

I'm wondering how I'd improve the app by doing something like this:
1. User starts app, load form A
2. App detects that user is new, UIAlert to say that User needs to register
3. The Registration Form (form B) automagically appears.

I tried implementing some logic in Form A's viewDidLoad like:

//initWithNib:@"RegisterForm" doesn't make a diff
RegisterForm *formB = [RegisterForm new]; 
formB.navTitle = [NSString stringWithFormat:@"Register New"];
[self presentModalViewController:formB animated:YES];
[formB release];

But that of course, doesn't work, so; can anyone tell me how what I'm doing wrong?

Thanks!

 -(void)viewDidLoad {

 If the user hasn't registered
 {    RegisterView *view = [[RegisterView alloc] initWithNibName:nil bundle:nil];
      [self presentModalViewController:view animated:YES];
      [view release];
 } else {

 }

 }

Or, if you're working with multiple views within one XIB file, define the view in the.h file, link it in the XIB file, and then in viewDidLoad, use the same if statement, but use this code instead:

[self.view bringSubviewToFront:registerView];

Hope this helps. Ask me any questions you have.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM