當我從上到下選擇行時,出現分隔符。但是當我滾動行時,分隔符被刪除。TableView分隔符消失
當我從下往上選擇行時,不會出現分隔符。
我該如何保持分隔符始終存在?
我已經搜索了一段時間,似乎還沒有解決方案。
當我從上到下選擇行時,出現分隔符。但是當我滾動行時,分隔符被刪除。TableView分隔符消失
當我從下往上選擇行時,不會出現分隔符。
我該如何保持分隔符始終存在?
我已經搜索了一段時間,似乎還沒有解決方案。
當你簡單地添加一個UITableView時,它會顯示這些分隔符。選擇,重新加載或執行任何其他功能時,分隔符會保留在那裏。
其他可以檢查分隔符是選擇默認還是不選。
在同一時間只能選擇單行。選擇顏色與分隔符相同。看起來沒有分隔符。另外,當你有多個選擇。它的默認功能似乎沒有分隔符。
// create a cell for each table view row
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
// create a new cell if needed or reuse an old one
let cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier(cellReuseIdentifier) as UITableViewCell!
// set the text from the data model
cell.textLabel?.text = mainArr[indexPath.row]
//Main item here is set selection style none.
cell.selectionStyle = UITableViewCellSelectionStyle.None
return cell
}
和當選擇的行中,添加新的UIView或ImageView的哪個是相同的寬度細胞視圖,但高度應cell.height-1
func tableView(tableView: UITableView, didDeselectRowAtIndexPath indexPath: NSIndexPath)
{
let cell = self.tableView.cellForRowAtIndexPath(indexPath)
var customView = UIView(frame: CGRectMake(0, 0, (cell?.frame.width)!, 43))
customView.backgroundColor = .redColor()
customView.alpha=0.3
cell!.addSubview(customView)
}
細胞
在這個管理算法中,通過這種方式,您可以知道是否必須選擇或取消選擇該行,並以這種方式添加視圖或從單元中移除視圖。
您是否添加自定義分隔符?或者你檢查是否你寫的任何地方self.tableView.separatorStyle = UITableViewCellSeparatorStyle.None – gurmandeep
不,我沒有這樣做。默認情況下,它不會顯示分隔符。會嗎? – henry
是的UITableView的默認屬性是顯示分隔符。你可以分享故事板的屏幕截圖,你已經添加了UITableView – gurmandeep