我有一個正在顯示在tableView中的自定義UITableViewCell。這個UITableViewCell是從一個nib文件生成的。 UITableViewCell中有一個UILabel。下面給出了它的代碼。顯然,我試圖將字體大小減小到一個固定大小,並且沒有任何東西可以工作。這是我目前正在設置的字體大小。UITableViewCell字體大小不變
在UITableViewCell中(這是附着在筆尖.m文件),這裏是我做
- (void)awakeFromNib
{
UIFont *myFont = [ UIFont fontWithName: @"Arial" size: 4.0 ];
self.LabelMyLabel.font = myFont;
}
這是如何被創建的TableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *TransferIdentifier = @"TransferTableItem";
FileTransferTableCell *cell = [tableView dequeueReusableCellWithIdentifier:TransferIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"FileCustomTableCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
//Set the text in the UITableViewCell here
cell.textLabel.text = [self.MyArray objectAtIndex:indexPath.row];
return cell;
}
我將不勝感激如果有人能幫我弄清楚爲什麼我的textsize總是不變的(我也減少了界面生成器中UITableViewCell中標籤的字體大小)?
嘗試將代碼移至'viewDidLoad'而不是'awakeFromNib'。 –
@Wongzigii表格單元格中沒有'viewDidLoad'。 – matt
你有沒有仔細檢查你的筆尖連接?是名爲textLabel的標籤嗎? – Siriss