2012-05-01 28 views
0

我不知道如何描述問題,而不是問題的標題:我有一個按鈕,其標題在點擊時出現,但不處於正常狀態。我環顧四周無濟於事。UIButton標題不會出現,除非點擊

如果您需要查看特定的代碼或需要其他詳細信息(我相信您會知道),請讓我知道。

編輯:該按鈕是在筆尖中創建的,但這裏是設置標題和處理按鈕的子視圖的代碼。

[chapterButton setTitle:[NSString stringWithFormat:@"%@: %d",newBookName,newChapter] forState:UIControlStateNormal]; 

UIImageView *triunghiView = (UIImageView *) [chapterButton viewWithTag:kTagTriangleView]; 
if(!triunghiView) 
{ 
    triunghiView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"triunghi.png"]] autorelease]; 
    [triunghiView setContentMode:UIViewContentModeCenter]; 
    [triunghiView setTag:kTagTriangleView]; 
    [triunghiView sizeToFit]; 
    [chapterButton addSubview:triunghiView]; 

} 

[triunghiView setCenter:CGPointMake(chapterButton.titleLabel.frame.origin.x + chapterButton.titleLabel.frame.size.width + triunghiView.frame.size.width + 5, chapterButton.frame.size.height/2)]; 
+1

如果沒有人會問,你會不會顯示代碼?它是一個顯而易見的事情,你必須展示代碼。 – Sarah

+1

你能告訴我們那裏的代碼初始化了嗎?或者這個按鈕是在.nib文件中創建的? –

+0

莎拉我不確定你希望看到哪部分代碼。所以最好先問。 :) –

回答

3

最近我有這個問題,你也必須設定按鈕的標題顏色,否則它會變成白色,並出現隱形(圓形矩形按鈕的默認設置)。

[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];

但是,它也有可能成爲Kjuly的回答!沒有代碼很難說。

+0

哦,我的天啊,我簡直不敢相信這是簡單的。我的按鈕是黑色的,所以我只是將標題更改爲whiteColor。謝謝您的幫助! –

0

沒有代碼,好吧,猜猜你可能爲你的標題設置了錯誤的狀態。

[yourButton setTitle:@"Title" forState:UIControlStateNormal];