Hi in my project i need to update a label according to the events performed.Suppose am interacting with the server then the label should display following text 1.Connecting to the server 2.Received response from the server etc help me i struck here
A:
You have to create the outlet of UILabel. and then set the "labelname.text" to what u want according to the event.
Jack
2010-09-27 08:17:44
ya i tried it but the second event is not updating the text.
iphoneStruggler
2010-09-27 08:47:02
u should post some fraction of ur code to complete ur question. post the lines where u have problem.
Jack
2010-09-27 09:12:44
i have placed a label on the view through interface builder.In .h file i declared IBOutlet UILabel *lblmsg;In .m - (void)connectionDidFinishLoading:(NSURLConnection *)connection{ [self CompleteWebRequest]; NSLog(@"Request is loaded successfully"); lblmsg.text=@"Request is loaded successfully";}and in another event am updating it as lblmsg.text=@"displaying images";While in debugger the label is updating but in the view it is showing the previous text
iphoneStruggler
2010-09-27 09:27:01
check the second event using NSLog whether control goes in that or not.check the connections in xib. if it doesn't solve ur problem then send ur lines of code for creating label and its outlet, may be there is some problem in this.
Jack
2010-09-27 10:59:58
hey guys i got the solution am placing the labels code in wrong places thats why labels are not showing now its working.........Thanks alot for all of you
iphoneStruggler
2010-09-29 07:59:34
A:
you can set the text property of the label for setting text.
For example: In While connecting to the server event:
myLabel.text=@"Connecting to the server";
In the event When you recieve response
myLabel.text=@"Received response from the server";
and so on....
ADD LABEL THROUGH CODE This is how to add the label through code because i cant show the binding here in .h file
UILabel* myLabel;
in .m file viewDidLoad (Note: Dont alloc the label again in code except here)
myLabel=[[UILabel alloc]initWithFrame:CGRectMake(10,10,200,40)];//SET THE FRAME ACCORDING TO YOUR USE
[self.view addSubview:myLabel];
myLabel.text=@"Initial Text";
Release the label
- (void)dealloc {
[myLabel Release];
}
hAPPY cODING...
Suriya
2010-09-27 08:26:23
i tried this thing but the label is not updating to the second message.
iphoneStruggler
2010-09-27 08:46:18
The reason may be that you have allocated the label again or your label is not properly binded. Check whether its binded properly in xib or not.
Suriya
2010-09-27 09:06:31
+1
A:
Your question could be more complete.
If you're doing things programmatically you need to call the setText:
method on your instance of UILabel with the new message each time. Something like:
//In practice use a smaller frame.
UILabel *label = [[UILabel alloc] initWithFrame:[window bounds]];
[label setText:@"Waiting for the server to do something interesting..."];
[window addSubview: label];
//later on....
[label setText:@"The server just sneezed! What shall I do?"];
SpecialK
2010-09-27 08:26:44