954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Display another view when triggered

hi! i am new to objective c programming. i am making a quiz application. i have a home screen which options like: view instructions and start quiz. how can i display another view when i click a button. like, i want to display the instruction screen when i click instructions.

can you help me with this one?

loraine96
Newbie Poster
8 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

If you have created the view in a nib file then you load the view from the current one. Inside the code for the button press you would have something like:

UIView *quizz = [[UIView alloc] initWithNibName: @"qizzView" bundle: nil];
[currentView addSubView:quizz];

Or possibly the superview would add the subview depending on how you have it set out and want the views to display.

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 167
 

You said you were new to Objective C. Here is a sheet example. I did notice you said view and I am displaying a sheet not a view.
This is a verbose code sample and not a best practice example. I often teach Windows programers how to move to Objective C and bloated codes often helps..

/* Declaration */
- (IBAction)executeAction:sender;


/* Action */
- (IBAction)executeAction:sender
{
dlgConnection = [[ConnectionMgrDlg alloc]init];

if(dlgConnection)
{
*/ params globally declared */
if(!params)
params = [[Params alloc] init];

/* Init and close to attach as a sheet */
[dlgConnection showWindow:self];
[[dlgConnection window] setDelegate:dlgConnection];
[dlgConnection close];
[dlgConnection setDataValues:params];

/* Show dialog (sheet) with a response method of didEndExecuteAction */
[NSApp beginSheet:[dlgConnection window] modalForWindow:window modalDelegate:self didEndSelector:@selector(didEndExecuteSheet:returnCode:contextInfo:) contextInfo:NULL];
}
}

- (void)didEndExecuteSheet:(NSWindow *)dlg returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo
{
switch(returnCode)
{
case -1: // Cancel
[dlg orderOut:self];
break;
case 1:
if(params)
{
...
}
[dlg orderOut:self];
break;
}
[dlg release];
dlg = nil;
}
[/CODE]hi! i am new to objective c programming. i am making a quiz application. i have a home screen which options like: view instructions and start quiz. how can i display another view when i click a button. like, i want to display the instruction screen when i click instructions.

can you help me with this one?

TPBarnett
Newbie Poster
3 posts since Feb 2007
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: