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.
TYVM you've solved all my proeblms
FHrL2z , [url=http://skfwydbkxqcn.com/]skfwydbkxqcn[/url], [link=http://rdyizqiinbhu.com/]rdyizqiinbhu[/link], http://yoybloghtggj.com/
http://www.shopdiazepamfast.com/ - valium order buy valium online valium buy valium without prescription http://www.shopdiazepamfast.com/
9ISRSN vwlvttafyoxj, [url=http://swytthxsbiix.com/]swytthxsbiix[/url], [link=http://bubzifklsuji.com/]bubzifklsuji[/link], http://hcujcdfbmatp.com/
Hello! dcadkdd interesting dcadkdd site! I'm really like it! Very, very dcadkdd good!
Very nice site! [url=http://ypxoiea1.com/ovyxrvv/2.html]cheap cialis[/url]
Very nice site! cheap cialis http://ypxoiea1.com/ovyxrvv/4.html
Very nice site!
Hello! ekeaded interesting ekeaded site! I'm really like it! Very, very ekeaded good!
Very nice site! cheap viagra
Very nice site! cheap cialis http://ypxoiea1.com/ovyxrvv/4.html
(11) Responses to this post