假设有一个iphone项目的代码是:
IBOutlet UITextField* numberDisplay;
@property (strong,nonatomic) IBOutlet UITextField *numberDisplay;
Run Code Online (Sandbox Code Playgroud)
在实现文件和
@synthesize numberDisplay;
在实施文件中.同样在实施中
-(IBAction)numberClicked:(id)sender {
UIButton *buttonPressed = (UIButton *)sender;
int val = buttonPressed.tag;
if ( [numberDisplay.text compare:@"0"] == 0 ) {
numberDisplay.text =[NSString stringWithFormat:@"%d", val ];
} else {
numberDisplay.text = [NSString
stringWithFormat:@"%@%d", numberDisplay.text, val ];
}
}
Run Code Online (Sandbox Code Playgroud)
当我运行应用程序时,UITextfield中没有显示任何显示,即使连接是使用IB进行的,并且已经证明是通过查看检查器进行的.即使作为测试,如果我添加线条
numberDisplay.text = @"a";
NSLog(@"the value is %@",numberDisplay.text);
NSLog(@"the value is %@",numberDisplay);
Run Code Online (Sandbox Code Playgroud)
我得到"两个案例中的值都是(null).任何想法.
有人可以告诉我这两行有什么问题吗?谢谢.
谢谢大家.我从零开始,现在一切正常.看起来我有一个贴错标签的文件.