4

i just want to modify the size of character of the UITextView. until now is possible to attach the string, but i Try to change the dimension: is not possible. As i searched into the Forum i found that some people got it selecting Editable and deselecting it. Other people got it by selecting Selectable from the View properties. Then i tried this way... no way to change. Only Plain text.

import UIKit
@objc(TextControllerSwift) class TextControllerSwift: UIViewController {

var selectedMovie: String?
var textPlaying: String?

@IBOutlet weak var textMuseum: UITextView!
override func viewDidLoad() {
    super.viewDidLoad()
    realPlay()
}

func playText(textSelect: String) {
textPlaying = textSelect 
}

//Giving the time to Segue method to wakeup.
func realPlay(){
var textRoom: String?

//reading the file .txt
let path = NSBundle.mainBundle().pathForResource(textPlaying, ofType:"txt")
if (path != nil){
        do {
      textRoom= try String(contentsOfFile: path!, encoding: NSUTF8StringEncoding)  
//here i'm getting the string.
}
catch {/* ignore it */}
//i tried it these options...
textMuseum.editable=true
textMuseum.selectable=true  
textMuseum!.text=""

//Got the text, now i put into UiView
textMuseum.font = UIFont(name: "Arial-Unicode", size: 50)
textMuseum.text=textMuseum.text.stringByAppendingString(String(textRoom!))
}}}

hmmm where am i getting wrong? because i changed the textMuseum font. Should i free some Costraint on the UITextView Object put in the StoryBoard? also with the editable and selectable removed the result is the same. why?

thank you for every help.

EDIT: Added Git Repository - No Working Video as i deleted this part. To see the problem just click on uisegmented "testo" and select play or the table.

https://github.com/sanxius/TryText.git

2
  • check your font family contains font is available or not, if it is available check the space and names once Commented Oct 5, 2015 at 14:39
  • @Anbu.Karthik i changed the font and i put the HelveticaNeue (system standard) ... the same result. Commented Oct 5, 2015 at 17:14

1 Answer 1

2

After reviewing your source code:

  1. Make UITextView selectable: textMuseum.selectable = true
  2. If you want to use custom font then do not forget it's file name to add it to Info.plist Fonts provided by application array.
  3. Use existing font name. There is no font with name Arial-Unicode. Arial-Unicode.ttf is file name not font name.

You can find your font name by listing all loaded fonts with:

for familyName in UIFont.familyNames() {
    for fontName in UIFont.fontNamesForFamilyName(familyName) {
        print(fontName)
    }
}

Also iOS has built-in Arial font that can be loaded by UIFont(name: "ArialMT", size: 50). So you do not need to add your Arial-Unicode.ttf.

Sign up to request clarification or add additional context in comments.

7 Comments

i Put Arial-Unicode into the project. anyway i'll try.
@SanXiuS Did you your font to Info.plist Fonts provided by application array?
no. That's strange. i'm trying to understand what's wrong with this. Because it get the string from the file, so it's the right Object. hmm maybe something is being bring to reset when shown up?
Could you place your project on GitHub and send me a link?
i'll try to put the project on GitHub. few minutes :D
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.