2011-08-27 131 views
0

我已經檢查了其他類似的問題,並完成了那些內容,我認爲,但是我的自定義字體仍然沒有顯示在UI按鈕上。UIButton自定義字體沒有顯示

字體在項目中,並且它在我的UITableViewCells中正確顯示,所以我知道該字體工作正常。

我加載視圖,並將字體分配給按鈕,但是當我運行該應用程序時,它沒有顯示正確的字體。

FirstViewController.h

@interface FirstViewController : UIViewController <UITextFieldDelegate, UITableViewDelegate, UITableViewDataSource> { 
    ...  
    UIButton *searchButton; 
    ... 
} 

... 
@property (nonatomic, retain) IBOutlet UIButton *searchButton; 
... 

@end 

然後我在FirstViewController.m

@synthesize searchButton; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad];  

    self.searchButton.titleLabel.font = [UIFont fontWithName: @"FontFile" size: 11.0 ]; 
} 

得到這個我做了什麼錯?

+0

確保searchButton連接IB。 – jamihash

+0

檢查您的searchButton屬性是否在接口文件中連接。 –

+0

是否正確單擊,然後將引用出口拖動到文件的所有者,然後從彈出窗口中選擇「searchButton」?在IB –

回答

0

正如jamihash指出的,我沒有將IB的按鈕連接到代碼。這樣做解決了它。

1
[self.searchButton setTitle:@"ButtonTitle" forState:UIControlStateNormal];