The image attached says it all. Is there any way to prevent the title from overlapping such as automatically moving to a second line whenever it reaches its limit? programatically/through interface builder.
P.S: im retrieving the names from firebase database. this is a voting page and title are the booth names
TableView Controller
import UIKit
import FirebaseDatabase
var pitchData = [String]()
var myIndex = 0
class PitchTableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.setNavigationBarHidden(false, animated: true)
self.navigationController?.navigationBar.titleTextAttributes = [ NSAttributedStringKey.font: UIFont(name: "Gotham Rounded", size: 19)!]
ref = Database.database().reference() //set the firebase reference
// Retrieve the post and listen for changes
databaseHandle = ref?.child("Afternoon13").queryOrdered(byChild: "BoothPosition").observe(.value, with: { (snapshot) in
pitchData.removeAll()
for child in snapshot.children {
let snap = child as! DataSnapshot
let key = snap.key
pitchData.append(key)
}
self.tableView.reloadData()
})
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return pitchData.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
cell.textLabel?.font = UIFont(name: "Gotham Rounded", size: 20)
cell.detailTextLabel?.font = UIFont(name: "Gotham Rounded", size: 20)
cell.textLabel?.text = pitchData[indexPath.row]
switch (pitchData[indexPath.row]) {
case "ARC - attract, retain and cultivate":
let returnValue: Int = UserDefaults.standard.integer(forKey: "voting")
if (returnValue == 1)
{
cell.detailTextLabel?.text = "Completed ✓"
cell.detailTextLabel?.textColor = UIColor.green
cell.isUserInteractionEnabled = false
}
else {
cell.detailTextLabel?.text = "Vote ᐳ"
cell.detailTextLabel?.textColor = UIColor.blue
}
case "Anytime RCs":
let returnValue: Int = UserDefaults.standard.integer(forKey: "voting1")
if (returnValue == 1)
{
cell.detailTextLabel?.text = "Completed ✓"
cell.detailTextLabel?.textColor = UIColor.green
cell.isUserInteractionEnabled = false
}
else {
cell.detailTextLabel?.text = "Vote ᐳ"
cell.detailTextLabel?.textColor = UIColor.blue
}