2016-03-07 20 views
1

我有一個動態的Prototype TableView。因爲我想在單元格中顯示一條線,所以我拖動一個uview並放置在單元格中。問題是,當我在移動設備上編譯應用程序時,該行並未顯示在單元格中。我在我的代碼這樣做是爲了填充單元格值在tableView中顯示自定義表分隔符UIView

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { 
    let cell = tableView.dequeueReusableCellWithIdentifier("cell", 
     forIndexPath: indexPath) as! RequestTableViewCell 

    cell.userNameLabel.text = firstName.uppercaseString + " " 
     + lastName.uppercaseString 

    cell.contentView.addSubview(cell.tableSeparatorUIView) 
} 

我想我在這裏做得不對

cell.contentView.addSubview(cell.tableSeparatorUIView) 
+0

嘗試將UIView設置爲單元格contentView而不是cell.UIView ---'cell.contentView.addSubview(tableSeparatorUIView)' – Rahul

回答

0

這樣做: -

選擇您的TableView做分離器沒有在屬性檢查器。然後在底部添加UIView,高度爲1px,前導,尾部,底部添加到tableView。 。