Sunday, July 25, 2010

Short post on navigating between views.

In this article, we will go through how to incorporate multiple views into our application. By default, creating a new View-based project in Xcode gives you a View. To create a second view, right click on classes, select Add new View class with xib file. That will give you a new ViewController class along with its xib file.

The below example code shows you how you can link your first view to your second view and back from second view to your first view. Remember to import the .h file of the View.

OctopusAnswer *octupusAnswer = [[OctopusAnswer alloc] initWithNibName:@"OctopusAnswer" bundle:nil];
[self.view addSubview:octupusAnswer.view];

octupusAnswer.answer.text = [tmpAns stringByAppendingString:@"!"];

// on the other form
[self.view removeFromSuperview];

No comments:

Post a Comment