Pages

Sunday, April 4, 2010

Iphone : Hello World First Application.

Here i Use only Simple Code to Define the Application and not use so much Detail to confuse u.
so just use it and execute the application.

In .h File of Hello world,
first we declared A UIButton Object and then Connect them with Interface Builder.

.h file As

IBOutlet UIButton *msg;

@property (retain,nonatomic) UIButton *msg;

- (IBAction) displayMsg:(id)sender;



.m file.......


Here We define the DisplayMsg function on touch inside up event and here we use UIAlertView Class to show the HelloWorld Msg.


- (IBAction)displayMsg:(id)sender
{
s_msg.text = @"";
UIAlertView *str =[[UIAlertView alloc] initWithTitle:@"Alert MSG" message:@"HELLO WORLD" delegate:self cancelButtonTitle: @"NO" otherButtonTitles:@"YES",nil];
str.delegate = self ;
[str show];
[str release];

}

Now we have to define Delegate method of UIAlertView such as:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
// NO = 0, YES = 1
if(buttonIndex == 0)
s_msg.text = @"NO";
else {
s_msg.text = @"YES";
}


use it to build your first application on Iphone.

And Post Comment on it and if u have any Problem.


thanks

No comments:

Post a Comment