2015-08-18 93 views
0
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell 
{ 
    let myCell = tableView.dequeueReusableCellWithIdentifier("myCell",  forIndexPath: indexPath) as! UITableViewCell 


    myCell.textLabel?.text = searchResults[indexPath.row] 
    myCell.textLabel?.font = UIFont(name: "Lato", size: 18) 
    myCell.textLabel?.lineBreakMode = NSLineBreakMode.ByWordWrapping 
    myCell.textLabel?.numberOfLines = 0 



    return myCell 
} 

这是我利用改变我的细胞的视觉特性的代码块,我相信我应该得到换行/字包裹,但它减少不管。自动换行编程是不工作,因为它应该

enter image description here

+2

myCell.textLabel约束或大小有问题。确保标签的大小等于单元格的大小,限制是正确的 –

回答

0

它的工作正如所料,刚刚不是你的。
文件称:

ByWordWrapping
包装发生在单词边界,除非 词本身不适合在一行。请参阅Characters and Grapheme ClustersString Programming Guide讨论 与确定字边界有关的问题。

适用于iOS 6.0及更高版本。

您可以改用ByCharWrapping。或者你应该相应地设置你的标签的框架。

相关问题