I have this project where I use drop down options, which content are changing from time to time. Right now, if the content is wider than the width of the drop down, you will not be able to see all of the content. I want the options to be higher, the more content there are, so you always are able to see everything no matter how long the content are. I have tried following various guides on the internet, but the problem is that they have all made their tableViews in the viewController, and I have made mine programmatically. I hope it all makes sense. You can see the problem and my code if you follow the link below
https://github.com/Rawchris/See-all-text-of-drop-down
I hope you are able to help ;)
add these lines to override init(frame: CGRect)
tableView.estimatedRowHeight = 50
tableView.rowHeight = UITableViewAutomaticDimension
then add numberOfLines = 0 to your UITableViewCell
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = UITableViewCell()
cell.textLabel?.text = dropDownOptions[indexPath.row]
cell.textLabel?.numberOfLines = 0
cell.backgroundColor = UIColor.darkGray
return cell
}