xcode 如何从 iPhone sdk 中的标签获取文本字段值?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11776927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:07:00  来源:igfitidea点击:

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

iphoneiosxcodeios4

提问by Jaspreet Singh

if i have a tag of text field then how can i pick the value of textfield in iPhone sdk

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

回答by Bruno Koga

you should be fine with something like (assuming that the TextField is a self.view's subview):

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

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

回答by Kamar Shad

Try below one

试试下面一个

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

回答by ravinder521986

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

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

回答by Midhun MP

Use:

用:

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

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

You need to replace 100 by your own tag.

您需要用您自己的标签替换 100。