tags:

views:

43

answers:

2

What is the better code to move from "page" to "page"?I have a questionnaire on 4 pages and I loading 4 views from 4 xibs.

I picked up 2 way of moving from xib to xib (in my case, from page to page). Method 1:

-(IBAction) MaleTapped: (id) sender {
    Page1M *ivc = [[Page1M alloc] init];
    UINavigationController *nc = [[UINavigationController alloc]
                                  initWithRootViewController:ivc];
    [self presentModalViewController:nc animated:NO];
    [ivc release];
    [nc release];
}

Second way:

-(IBAction)GotoPage2M:(id)sender {
    page2M = [ [Page2M alloc]
              initWithNibName:@"Page2M" bundle:nil];
    [self.view addSubview:page2M.view];}

One method uses the RootViewController method, the second just loads the subview. For my 4 pages, which is the better/cleaner/smarter way?

A: 

I would recommend using a UINavigationViewController in this way. Going several modal views deep is icky.

- (IBAction) goToNextPage:(id)sender {
    UIViewController * newView = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
    [self.navigationController pushViewController:newView animated:YES];
    [newView release];
}

The only reason I might do subviews is for the extra transition options.

Cory Kilger
Cory, this is not working, both previous are working, this one for some reason is not. The next nib is pretty involved with delegate and such...... Can't tell you why, but this is not working.... it builds fine, no error messages when i press the button for IBAcation, but it is not working. I understand that I do not want subviews or modal views. But the usual way does not work for me. Any other suggestions?
A: 

I would recommend checking out Apple's sample Page Control code. It shows how to create something that pages through multiple view controllers and load them dynamically from xibs. The example just loads the same xib several times, but you could replace it with code that loads a different view controller or xib for each page.

samkass
Sam,I like that, but for now.... I like it a lot, thanks......but for now, I just need to flip some views/pages and get the "proof of concept" app done....