Question Answer Tut in Iphone


In this tutorial we will see how can we calculate the correct Answer.This is the view based apps. Here are some steps for it…


1. Open the xcode & choose "File->New Project".

2. Select "Application" from left menu and then "View-based Application".

3.Name your project as "QusAns" and save the project.

4.Now just select "QusAnsViewController.h" file from left menu for define a  Four UIButtons, and Five UILabels . Set the property for UIButtons, UILabels . And define a method firstAnswer,secondAnswer,thirdAnswer,cleanAnswer as IBAction.

 

#import <UIKit/UIKit.h>


@interface QusAnsViewController : UIViewController {

IBOutlet UILabel *Qus;

IBOutlet UILabel *selectLabel;

IBOutlet UILabel *answer1;

IBOutlet UILabel *answer2;

IBOutlet UILabel *answer3;

IBOutlet UIButton *firstAnswerButton;

IBOutlet UIButton *secondAnswerButton;

IBOutlet UIButton *thirdAnswerButton;

IBOutlet UIButton *cleanAnswer;


}

-(IBAction)firstAnswer:(id)sender;

-(IBAction)secondAnswer:(id)sender;

-(IBAction)thirdAnswer:(id)sender;

-(IBAction)cleanAnswer:(id)sender;

@end

 

5. Now select "QusAnsViewController.m" file from menu for implementation.

#import "QusAnsViewController.h"


@implementation QusAnsViewController


- (void)viewDidLoad {

Qus .text=@"what does 10*10 equal to?";

answer1.text=@"";

answer2.text=@"";

answer3.text=@"";

    [super viewDidLoad];

}

-(IBAction)firstAnswer:(id)sender{


if (Qus.text==@"what does 10*10 equal to?") {

answer1.text=@"wrong answer!!";

answer1.textColor=[UIColor redColor];

}



}


-(IBAction)secondAnswer:(id)sender{


if (Qus.text==@"what does 10*10 equal to?") {

answer2.text=@"wrong answer!!";

answer2.textColor=[UIColor redColor];

}


}

-(IBAction)thirdAnswer:(id)sender{


if(Qus.text==@"what does 10*10 equal to?"){

answer3.text=@"correct answer!!";

answer3.textColor=[UIColor blackColor];

}


}

-(IBAction)cleanAnswer:(id)sender{

answer1.text=@"";

answer2.text=@"";

answer3.text=@"";




}



- (void)dealloc {

    [super dealloc];

}


@end

 

 

6. Now double click on "QusAnsViewController.xib" from Resource folder for open it.


7. On the view window drag the Button,Label from library . Then link the Button, Label  to the File's Owner. And link the button to IBActon method.


8. Then Quit and Save the Interface Builder.


9. Now you are ready for  click on "Build & Go" button. 


Now you can see the output in iphone simulator .

 

 

 

 

 

 



(4) Responses to this post

Graceland Oct 31 2011 at 18:02:42

Whoever edits and publishes these arctiles really knows what they're doing.

pimfxn Nov 01 2011 at 08:29:03

M1S8CG vacxckuxsbsp

beytlf Nov 03 2011 at 05:58:29

kDKDze , [url=http://dlfayezmjleq.com/]dlfayezmjleq[/url], [link=http://moacskmtzgdc.com/]moacskmtzgdc[/link], http://jrbicnsaxzvu.com/

valium Mar 15 2012 at 00:47:03

http://www.shopdiazepamfast.com/ - buy valium online without prescription order valium cheap cheap valium online buy generic valium http://www.shopdiazepamfast.com/


Leave your comment here






User Login




New User Forgot password

Newsletter Subscribe

Advertisement

 
 
 
quick contact