在控制器中我有标签属性:
@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上它不会改变。
答案 0 :(得分:0)
尝试将您的标签设置为强。
@property (strong, nonatomic) IBOutlet UILabel *ScoreLabel;