4

SYBListWeiBoCellView is a custom cell and it has a UITextView. I set the font of the UITextview in storyboard, and make a IBOutlet in SYBListWeiBoCellView called repoText. When I get the SYBListWeiBoCellView through

SYBListWeiBoCellView *cell = [tableView dequeueReusableCellWithIdentifier:@"weiboCell"];
UIFont *font = cell.repoText.font;

the font turns nil, it should be the value I set in storyboard.

here https://stackoverflow.com/a/19115950/1130175 someone say it's a bug.

Community
  • 1
  • 1
Xiao Ming
  • 131
  • 1
  • 12
  • 1
    Font nil? Can you please elaborate what the problem is? – Meera Nov 04 '13 at 07:59
  • ok, the font of UITextView is nil, it should be the value I set in storyboard. – Xiao Ming Nov 04 '13 at 08:18
  • Are you accessing the UITextfield? Try setting the font using [self.yourTextView setFont:]. I think you are not pointing to the textview reference. Also check whether IBOutlet is connected? Why accessing contentView from cell's reference? – Meera Nov 04 '13 at 13:26
  • no, accessing the UITextView.It just a problem that I can't get the attribute that I define in the storyboard. I fix it by checking the "selectedable". I don't konw why it works , someone say it a bug. – Xiao Ming Nov 05 '13 at 02:09
  • 1
    Remove that UITextView and add a new one. Sometimes this happens. I used to get this kinda behavior on UILabels. – Meera Nov 05 '13 at 03:48
  • There's 2 approach: (1) Mark the property "selectable" at the TextView element. (2) implement viewWillLayoutSubviews: then setFont at this moment; – orafaelreis Mar 09 '15 at 21:57

1 Answers1

0

If you use custom font, the font you select inside storyboard won't appear inside the application. You have to add the custom font file to your bundle and set the font inside the code.

You may follow this tutorial to add custom fonts: http://www.developers-life.com/how-to-include-ttf-fonts-to-ios-app.html

slecorne
  • 1,720
  • 1
  • 11
  • 14
  • The font is not custom.The cell is custom, and the has a UITextView, the font is own to the UITextView. – Xiao Ming Nov 04 '13 at 16:01