0
在控制器設置文本我有標籤屬性:無法爲標籤
@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上它不會改變。
在您的筆尖或故事板視圖上,您是否將標籤連接到了ScoreLabel?你是否確定UpdateScore被調用? – MichelleJS
是的,我連接它。 UpdateScore總是被調用。 – netmajor
如果您在'UpdateScore:'方法中使用'NSLog(@「%@」,self.ScoreLabel)'',您會得到什麼? –