简体   繁体   中英

How can i get the textfield value from tag in iPhone sdk?

如果我有一个文本字段的标签,那么我如何在iPhone sdk中选择textfield的值

你应该没问题(假设TextField是一个self.view的子视图):

NSString *text = [(UITextField *)[self.view viewWithTag:THE_TAG] text];

NSString * text = [(UITextField *)[self.view viewWithTag:tag] text];

Try below one

UITextField *textField = (UITextField*)[self.view viewWithTag:tag_Number];
NSString* textString=[textField text];
//Use textString  further

Use:

UITextField *textField = (UITextField*)[self.view viewWithTag:100];

NSLog(@"%@",textField.text);

You need to replace 100 by your own tag.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM