代码来自Stanford CS193p。我添加了一个NSLog来检查它。标签似乎没有被初始化。任何想法?为什么UILabel没有初始化?
@interface AskerViewController() <UITextFieldDelegate>
@property (weak, nonatomic) IBOutlet UILabel *questionLabel;
@property (weak, nonatomic) NSString *question;
@end
@implementation AskerViewController
@synthesize questionLabel = _questionLabel;
@synthesize question = _question;
- (void)setQuestion:(NSString *)question
{
_question = question;
self.questionLabel.text = question;
NSLog(@"label is %@", self.questionLabel);
}
@end
的NSLog的结果是:
2012-07-31 01:56:45.177 Kitchen Sink[23931:f803] label is (null)
_what_的获取和设置?当他们被叫时他们会被打电话,你需要提供更多信息或者这个问题不能得到回答。 – jrturton 2012-07-30 15:23:27
你说得对。我修改了这篇文章,并提出了使问题具体的代码。 – Philip007 2012-07-30 18:11:26
您的UILabel已连接/链接到questionLabel吗? – 2012-07-30 18:12:35