Dynamic Hello World App on Label


In this tutorial you will learn how to change a label dynamically.This is hello world iphone example. 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 "Hello_World" and save the project.

4. Now just select "hello_worldViewController.h" file from left menu for define a UILabel and a UITextField. Set the property for UILabel and UITextField.

 

#import

@interface hello_worldViewController : UIViewController {
   
    IBOutlet UILabel *lbl_hello;
    IBOutlet UITextField *txt_hello;
   
}

@property(nonatomic,retain) UILabel *lbl_hello;
@property(nonatomic,retain) UITextField *txt_hello;


@end

 

 

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

 

 

#import "hello_worldViewController.h"

@implementation hello_worldViewController
@synthesize lbl_hello,txt_hello;

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    NSLog(@"HELLO WORLD");
    [super viewDidLoad];
    [txt_hello addTarget:self action:@selector(updateLabelUsingContentsOfTextField:) forControlEvents:UIControlEventEditingChanged];

}

-(void)updateLabelUsingContentsOfTextField:(id)sender{
   
    lbl_hello.text=[NSString stringWithFormat:@"%@",((UITextField *)sender).text];
}

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
   
    // Release any cached data, images, etc that aren't in use.
}


- (void)dealloc {
    [lbl_hello release];
    [txt_hello release];
    [super dealloc];
}

@end

 

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

7. On the view window drag the label and textfield from library And name the label Fill the Text box. Then link the label and textfield to the File's Owner.

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 and open Console.



(11) Responses to this post

Karess May 04 2011 at 23:24:53

TYVM you've solved all my proeblms

ofjxslpkz May 06 2011 at 06:21:07

FHrL2z , [url=http://skfwydbkxqcn.com/]skfwydbkxqcn[/url], [link=http://rdyizqiinbhu.com/]rdyizqiinbhu[/link], http://yoybloghtggj.com/

valium Mar 14 2012 at 20:54:21

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

yzinwo Apr 15 2012 at 17:01:07

9ISRSN vwlvttafyoxj, [url=http://swytthxsbiix.com/]swytthxsbiix[/url], [link=http://bubzifklsuji.com/]bubzifklsuji[/link], http://hcujcdfbmatp.com/

Pharmd152 May 16 2012 at 22:45:49

Hello! dcadkdd interesting dcadkdd site! I'm really like it! Very, very dcadkdd good!

Pharmb976 May 16 2012 at 22:48:03

Very nice site! [url=http://ypxoiea1.com/ovyxrvv/2.html]cheap cialis[/url]

Pharmd6 May 16 2012 at 22:48:12

Very nice site! cheap cialis http://ypxoiea1.com/ovyxrvv/4.html

Pharmk518 May 16 2012 at 22:48:20

Very nice site!

Pharmb281 May 16 2012 at 22:48:23

Hello! ekeaded interesting ekeaded site! I'm really like it! Very, very ekeaded good!

Pharmf834 May 16 2012 at 22:48:30

Very nice site! cheap viagra

Pharme949 May 16 2012 at 22:48:42

Very nice site! cheap cialis http://ypxoiea1.com/ovyxrvv/4.html


Leave your comment here






User Login




New User Forgot password

Newsletter Subscribe

Advertisement

 
 
 
quick contact