2011-03-10 43 views
1

下面的代碼基本上可以工作,只顯示結果時不顯示titleLabel。UIButton不顯示titleLabel

buttonRect只是一個包含按鈕幀的CGRect。我不認爲問題的原因在那裏,因爲按鈕顯示在他應該在的位置。

[contactButton.titleLabel center]沒有幫助,使子視圖titleLabel前面也沒有。

UIButton *contactButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
contactButton.frame = buttonRect; 

contactButton.titleLabel.text = @"Contact Someone!"; 
[contactButton addTarget:self action:@selector(showContactWindow) forControlEvents:UIControlEventTouchUpInside]; 

[self.tabBarController.view addSubview:contactButton]; 

我真的不知道是什麼原因導致這種情況。

回答

6
[myButton setTitle:@"Contact Someone!" forState:UIControlStateNormal];