开发者

how to use same field to take data into uitextfield and out the result on label

开发者 https://www.devze.com 2023-03-05 21:56 出处:网络
i am writing an application for t开发者_Go百科emperature converter in iphone i want use the same field for data input and output i.e single field which has properties of both uitextfield and uilabel.

i am writing an application for t开发者_Go百科emperature converter in iphone i want use the same field for data input and output i.e single field which has properties of both uitextfield and uilabel. plz help. thanks


try :

-(IBAction)clculate
{
NSString *input =yourtetfield.text;  
Made some caculation   
................  
................  
 yourtetfield.text= result;  
}  

Note result is a string .


Just Try this....write this code on your buttonclick...

 -(IBAction)btnGoClicked:(id)sender
 {
     NSString *strTxtFiled = txtField.text;
     int intdata = [strTxtFiled intValue] * 2;
     txtField.text = [NSString stringWithFormat:@"%d",intdata];
 }

Here txtField is your TextField and I had done some calculation..you can do your calculation as explained here...


well,you can use uitextfield. It has an input (with the text property) and an output (with setText: ) Documentation of uitextfield


'myLabelVariable.text = myUITextfield.Text; is that what your on for?

0

精彩评论

暂无评论...
验证码 换一张
取 消