问题
I've tried various methods, which all give me warnings. Such as userName = [NSString stringWithFormat:@"%@", [yournamefield stringValue]]; which just gives me a warning of
'UITextField' may not respond to '-stringValue'
How do i do this?
回答1:
Get the text inside the text field using the text property
NSString *name = yourNameField.text;
回答2:
Use the text property of UITextField:
NSString *userName = yourNameField.text;
回答3:
How about:
userName = [NSString stringWithFormat:@"%@", yournamefield.text];
回答4:
Two ways. It is a property and any property value can be accessed like this -
yournamefield.text[yournamefield text]
来源:https://stackoverflow.com/questions/4660200/how-do-i-get-the-text-from-uitextfield-into-an-nsstring