We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,578 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

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?

3
Contributors
2
Replies
1 Month
Discussion Span
1 Year Ago
Last Updated
3
Views
JakeA
Newbie Poster
9 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 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
Veteran Poster
1,065 posts since Nov 2007
Reputation Points: 156
Solved Threads: 228
Skill Endorsements: 10

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;
}

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
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.2958 seconds using 2.66MB