在控制器中我有标签属性:
@interface BallsViewController : UIViewController <UIInteraction>
@property (weak, nonatomic) IBOutlet UILabel *ScoreLabel;
-(void)UpdateScore:(int)score;
@end
@interface BallsViewController ()
@end
@implementation BallsViewController
@synthesize ScoreLabel;
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)UpdateScore:(int)score
{
NSString *scoreStr =[NSString stringWithFormat:@"%d",score];
[self.ScoreLabel setText:scoreStr];
[self.InfoLabel setText:scoreStr];
}
@end
UpdateScore 是协议方法。当我想将文本设置为 ScoreLabel 时,它具有值:ScoreLabel UILabel * 0x00000000
这意味着它没有初始化?
当我设置文本时,在 ui 上它不会改变。