Xcode:Swift - Table Cell没有显示所有文本

时间:2015-05-04 01:03:23

标签: ios uitableview swift

我的细胞正在使文字正常,但它们没有显示所有文字。

图片:http://i.imgur.com/Aql1meS.png

以下是我的表视图控制器的代码:

class ResultsTableViewController: UITableViewController {

var mapItems: [MKMapItem] = [MKMapItem]()

override func viewDidLoad() {
    super.viewDidLoad()

}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    // Return the number of sections.
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    // Return the number of rows in the section.
    return mapItems.count
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCellWithIdentifier("resultCell", forIndexPath: indexPath) as! ResultsTableCell

    if(indexPath.row % 2 == 0) {
        cell.backgroundColor = UIColor.clearColor()
    }else{
        cell.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.2)
        cell.textLabel?.backgroundColor = UIColor.whiteColor().colorWithAlphaComponent(0.0)
    }

    // Configure the cell...
    let row = indexPath.row
    let item = mapItems[row]
    cell.nameLabel.text = item.name
    cell.phoneLabel.text = item.phoneNumber
    return cell
}

}

我已经四处搜索,看看我是否设置了字符限制,但似乎无法找到任何内容。提前谢谢。

1 个答案:

答案 0 :(得分:0)

您的UILabels似乎不够广泛。如果你把它们做得更宽,(或者在所有4个方面应用自动布局,那么......这会变得更加复杂),那么它应该可以正常工作。

希望这会有所帮助!!

相关问题