2015-08-18 85 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。或者你應該相應地設置你的標籤的框架。

相關問題