首页 文章

将文本标签从UIButton分配给UILabel不起作用

提问于
浏览
0

我在.h中声明了这一点

IBOutlet UILabel *display;

在.m我正在做以下但它不工作,继续说displat.text是null . 困惑,帮忙!是的我是菜鸟 .

NSLog(@"operation button pressed %@ is of class %@",[[sender titleLabel] text],[[[sender titleLabel] text] class] ); 
NSString *operation = [[sender titleLabel] text];
[display setText:operation];
NSLog(@"display text is of class %@ and equals %@",[display.text class], [display text]);

我也尝试过这样:

NSLog(@"digit button pressed %@ is of class %@",[sender currentTitle],[[sender currentTitle] class] );
display.text = (NSString *)[[sender titleLabel] text];
NSLog(@"display text is of class %@ and equals %@",[display.text class], [display text]);

1 回答

  • 0

    要检查两件事:

    • 确保在Interface Builder中连接了"display"插座 .

    • 在调用此代码之前,请确保您的接口已满载 .

    关于第2项,如果您告诉我们调用此问题代码的位置(从何种方法),则更容易为您提供建议 . 这是一个动作还是在启动时?哪里?

相关问题