我在UIButton中使用插入標籤addSubView
iphone:標籤值超過寫。
這裏標籤的值每次都會改變。
UILabel *backTopLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 30, 448, 66)];
backTopLabel.backgroundColor = [UIColor clearColor];
backTopLabel.textColor = [UIColor whiteColor];
backTopLabel.font = [UIFont fontWithName:@"Georgia" size:56];
backTopLabel.textAlignment = UITextAlignmentCenter;
backTopLabel.text = [[selectedUsers objectAtIndex:userIndex] valueForKey:@"FirstName"]; // UserIndex will be change and new data will be load in the label
[btnBackLeftCard addSubview:backTopLabel]; // btnBackLeftCard is the UIButton
[backTopLabel release];
問題是:它成功地更改了標籤值,但它已經寫完了。
我正在通過舊標籤值獲取新標籤值。
我該如何解決這個問題?
你要更改標籤,每次運行的代碼塊? – JonB
是的,我每次運行此代碼。 – Devang
在添加新文本之前添加以下行: ** backTopLabel.text = @「」; ** backTopLabel.text = [[selectedUsers objectAtIndex:userIndex] valueForKey:@「FirstName」]; // UserIndex將被更改並且新數據將被加載到標籤中並且請不要分配它再次只是做它一次或更好地使它的屬性 – rptwsthi