开发者

Multiview Application

开发者 https://www.devze.com 2022-12-15 10:58 出处:网络
I am trying to develop an engineering program. My first view has a textfield where the user is required to enter \"e\" or \"s\", for the units to be used(english or si), which is stored in a variable

I am trying to develop an engineering program. My first view has a textfield where the user is required to enter "e" or "s", for the units to be used(english or si), which is stored in a variable es. The AppDelegate shows th开发者_开发知识库is first view through applicationDidFinishLaunching: method. I have a Objective-C source file, where I am writing my code. How do I load the next view with a number of textfields where the user has to enter some values to be saved in variables?


The easiest way to do it would be to build a Navigation Controller on the App Delegate. Then you can easily push and pop views onto and off of the Controller. Something like this (this would work well inside applicationDidFinishLaunching of your App Delegate):

// controller is defined in the header
controller = [[UINavigationController alloc] init];
controller.navigationBar.barStyle = UIBarStyleBlack;
...
// Build your UIView
SomeUIView *welcome = [[SomeUIView alloc] initWithNibName: @"Welcome" bundle: nil];
[controller pushViewController: welcome animated: NO];
[welcome release];
...
// Display the Controller's top view in the window
[window addSubview: controller.view];
[window makeKeyAndVisible];

Then to change Views (this code is applicable anywhere in your application):

SomeOtherView *Detail = [[SomeOtherView alloc] initWithNibName:@"Detail" bundle:nil];
[self.navigationController pushViewController: Detail animated:YES];
[Detail release];

Notice you can always get back to the Navigation Controller through "self".

Good Lick!

0

精彩评论

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

关注公众号