TableView中显示的iOS标头截断了titleForHeaderInSection返回的字符串

TableView中显示的iOS标头截断了titleForHeaderInSection返回的字符串,ios,swift,uitableview,Ios,Swift,Uitableview,我试图从控制器构建一个tableView,而不只是自己在故事板中构建静态单元。我从一个数组中填充了所有单元格,我希望节标题显示在另一个数组中numberOfSections…返回5。我有我的标题标题标题部分方法如下: override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? { return self.questions[section] } 我

我试图从控制器构建一个tableView,而不只是自己在故事板中构建静态单元。我从一个数组中填充了所有单元格,我希望节标题显示在另一个数组中<代码>numberOfSections…返回5。我有我的标题标题标题部分方法如下:

override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
    return self.questions[section]
}
我的
self.questions
数组:

let questions = ["Have you had difficulties participating in normal training and competition due to ankle problems during the past week?",
    "To what extent have you reduced your training volume due to ankle problems during the past week?",
    "To what extent have ankle problems affected your performance in the past week?",
    "To what extent have you experienced ankle pain related to your sport during the past week?",
    "Finished?"];

由于某种原因,当我运行应用程序时,标题只有一行,因此没有显示我想要显示的完整问题。这可能是什么原因造成的?基于其他问题和研究,我需要创建自己的观点吗

默认导航顶部栏不会显示那么长的字符串。如果不希望截断,您必须创建自己的自定义视图/顶栏。

可能需要实现
func tableView(tableView:UITableView,viewForHeaderInSection:Int)->UIView?
并返回一个带有标签的自定义标题


如果您将此标签的约束(顶部、底部、左侧和右侧)设置为其superview,并实现
func tableView(tableView:UITableView,heightForHeaderInSection:Int)->CGFloat
并计算字符串高度以返回右视图高度。

如何计算字符串高度?下面是一个关于此问题的答案