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
How can i get the textfield value from tag in iPhone sdk?
提问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。