UITextField settext不工作 [英] UITextField settext not working
本文介绍了UITextField settext不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是令我沮丧的。我是一个初学者程序员,无法弄清楚为什么文本没有改变。
This is frustrating the hell out of me. I am a beginner programmer and cannot figure out why the text is not being changed.
这里是我的方法,它应该设置一个UITextField的文本:
Here is my method which is supposed to set the text of a UITextField:
-(void)updateDays:(NSInteger)days
{
NSString* daysString = [[NSString alloc] initWithFormat:@"%d", days];
[daysTextField setText:daysString];
[daysString release];
}
无论什么原因都没有发生。
For whatever reason nothing is happening.
帮助被推翻!
推荐答案
行为什么不是这行工作,使用调试器或只是添加一个NSLog之前打印出相关的数据:
Anytime you have a frustration along the lines of "why isn't this line working", use the debugger or just add an NSLog before it to print out the relevant data:
NSLog(@"updateDays: %@ %@ <= %@", daysTextField, daysTextField.text, daysString);
然后你知道行(a)被执行,认为他们是,和(c)价值是合理的。
Then you know the line (a) is getting executed, (b) the variables are the ones you think they are, and (c) the values are reasonable.
这篇关于UITextField settext不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文