Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITextView - setting font not working with iOS 6 on XCode 5

I'm using storyboards for my UI. I was previously using XCode 4.6 and released on iOS 6. I have since updated to iOS 7 using XCode 5 and updated the Storyboard to work nicely with XCode 5. I have one issue though:

UITextView doesn't want to display font changes within code. Text colour changes work fine. Any other property changes are fine. Font, not at all. I was using a custom font, so I checked different fonts with different sizes (i.e. systemFontOfSize:) but that didn't work. The text view only shows the font that's set in the Storyboard. What could I be missing here? Are there any auto-layout constraints that mess with this sort of thing? I had a few issues with constraints during the migration, but as I said, the fonts work fine in iOS 7.

I guess it's something in the Storyboard that I'm missing, as if I create a UIViewController and add a text view in code, it works fine.

I'd put up some code, but I'm not sure it'd help at all in this case.

like image 456
Harry Avatar asked Oct 01 '13 10:10

Harry


People also ask

How do I change the font of text in Xcode?

Press xcode->preferences. select fonts and colors. select ANY font in the list and press cmd+a (select all fonts) select font size for all editor fonts at the bottom of the window.

How do I add custom fonts to storyboard Xcode?

In the storyboard , drag a UILabel to you interface,select the label , and navigate to the Attribute Inspector,click the right icon button of the Font select area.In the popup panel , choose Font to Custom, and choose the Family of you embeded font name.

How do I set the font family in Swift?

To change the font or the size of a UILabel in a Storyboard or . XIB file, open it in the interface builder. Select the label and then open up the Attribute Inspector (CMD + Option + 5). Select the button on the font box and then you can change your text size or font.


2 Answers

Even stranger, this only happens on iPhone, not iPad.

If you're setting the font in code and don't want an editable text view, do this:

textView.editable = YES; textView.font = newFont; textView.editable = NO; 
like image 94
jab Avatar answered Sep 24 '22 13:09

jab


In my case, it is matter of 'selectable' property of UITextView.

So I checked 'selectable' property of UITextView in Storyboard Editor to set it YES To set selectable

and later in viewWillAppear set this property to NO.

textview.text = @"some text"; textview.selectable = NO; 
like image 28
Satachito Avatar answered Sep 24 '22 13:09

Satachito