UILabel 问题阻止它更新文本
UILabel Issue preventing it from updating text
为什么如果您在 "viewDidLoad" 方法中将“.m”文件中的 UILabel 初始化为 0(我知道您为什么要这样做没有意义),它会导致 UILabel 的文本变得不可编辑吗?
示例:
// foo.h
int intVariable;
@interface Game : UIViewController{
IBOutlet UILabel *fooLabel;
}
// foo.m
@interface()
@end
@implementation FooGame
-(void)viewDidLoad {
[super viewDidLoad];
fooLabel = 0;
}
-(void)MethodFoo{
fooLabel.text = [NSString stringWithFormat:@"%i", intVariable];//<-This does nothing no matter what the value of intVariable.
}
提前致谢。
调用 fooLabel = 0;
与 fooLabel = nil;
相同。
这会将您的插座设置为 nil
。 fooLabel
的任何进一步使用都将是空操作。
为什么要 foo.text
更新 fooLabel
?
这是错字还是您在 MethodFoo
中尝试 fooLabel.text
?
更新:
已删除参数。
为什么如果您在 "viewDidLoad" 方法中将“.m”文件中的 UILabel 初始化为 0(我知道您为什么要这样做没有意义),它会导致 UILabel 的文本变得不可编辑吗?
示例:
// foo.h
int intVariable;
@interface Game : UIViewController{
IBOutlet UILabel *fooLabel;
}
// foo.m
@interface()
@end
@implementation FooGame
-(void)viewDidLoad {
[super viewDidLoad];
fooLabel = 0;
}
-(void)MethodFoo{
fooLabel.text = [NSString stringWithFormat:@"%i", intVariable];//<-This does nothing no matter what the value of intVariable.
}
提前致谢。
调用 fooLabel = 0;
与 fooLabel = nil;
相同。
这会将您的插座设置为 nil
。 fooLabel
的任何进一步使用都将是空操作。
为什么要 foo.text
更新 fooLabel
?
这是错字还是您在 MethodFoo
中尝试 fooLabel.text
?
更新:
已删除参数。