Reputation: 11671
I have a custom UITableViewCell that is being displayed in tableView. This UITableViewCell is generated from a nib file. The UITableViewCell has a UILabel in it.The code of this is given below.Apparently I have tried to decrease the font size to a fixed size and nothing seems to work.Here is what I am currently doing to set the font size.
In the UITableViewCell (this is the .m file attached to the nib) here is what I do
- (void)awakeFromNib
{
UIFont *myFont = [ UIFont fontWithName: @"Arial" size: 4.0 ];
self.LabelMyLabel.font = myFont;
}
This is how the TableView is being created
- (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;
}
I would appreciate it if anyone could help me figure out why my textsize is always constant (I have also decreased the font size of the label in UITableViewCell in interface builder) ?
Upvotes: 0
Views: 951
Reputation: 3777
Change cell.textLabel.text
to cell.LabelMyLabel
as it is setup in your nib.
Upvotes: 0
Reputation: 535944
The setting of the label's font is working. The problem is that you are setting the text of the wrong label. You are saying:
cell.textLabel.text = [self.MyArray objectAtIndex:indexPath.row];
That's the wrong label. You want to set the text of LabelMyLabel
, not textLabel
. They are two different labels.
Upvotes: 2