Long time reader, first time poster. I have searched all over for a solution but I am yet to find an answer that works.
Ok the problem: I have a UILabel which gets text dynamically assigned to it. If I resize the label to cover the entire view controller the text is stuck in the middle. I found a bunch of solutions which say to add the following code:
detailsLabel.numberOfLines = 0;
detailsLabel.sizeToFit()
However this doesn't do anything.
Can someone have a look at my code and provide suggestions?
import UIKit
class DetailsViewController: UIViewController {
@IBOutlet weak var detailsLabel: UILabel!
@IBOutlet weak var lbldetails: UILabel!
var selectedBeach : Beach?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
detailsLabel.text = selectedBeach?.greaterDetails
lbldetails.text = (selectedBeach?.beachName ?? "") + " Details"
detailsLabel.numberOfLines = 0;
[detailsLabel .sizeToFit()]
}
@IBAction func dismiss(sender: AnyObject) {
self.dismissViewControllerAnimated(true, completion: nil)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/