调整UITextView的大小以适应Swift中的内容

时间:2015-07-31 00:55:27

标签: ios swift uitextview

这是我的第二个视图,称为详细视图,我将文本从第一个视图带到详细视图。有些文本比其他文本更大,所以我试图将其文本视图自动更改以适应所需的文本量。我还是Swift的新手,所以对任何帮助表示赞赏。

import UIKit

class DetailViewController: UIViewController {


@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var symptomsTextView: UITextView!
@IBOutlet weak var stepsTextView: UITextView!
@IBOutlet weak var emergencyLabel: UILabel!
var medicalObject : MedicalInfo? = nil
var emergencyText = ""
var symptomsText = ""
var stepsText = ""


//Function to show text in labels and text views
override func viewWillAppear(animated: Bool) {
    //Adding text to the labels and text views
    emergencyLabel.text = emergencyText
    symptomsTextView.text = symptomsText
    stepsTextView.text = stepsText
}


override func viewDidLoad() {
    super.viewDidLoad()

}


override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

}

0 个答案:

没有答案