0
我的第一個iOS應用程序使用簡單的自定義單元格,但增強過濾tableView行導致延遲和沮喪。在線搜索過濾器行的幫助,閱讀Apple開發人員指南中的dataSource和委託協議,到目前爲止沒有運氣。過濾器tableView行不重新載入tableView
使用滑塊值刷新表格行。從線陣列(100項)提取數據到linefilter
數組(20)。然後要刷新/重新加載tableview。
Slider聲明爲0,並顯示所有行數組項。移動滑塊不會改變顯示。如果滑塊聲明爲1,則顯示20個過濾器項目。
相當新的Apple/Xcode/Swift所以沒有Objective C的知識。
任何答案可能會幫助我到達那裏。 吉姆大號
相關的代碼選擇:
@IBAction func moveSlider(sender: AnyObject) {
// Non-continuous ******
_ = false
// integer 0 to 5 ******
let slider = Int(lineSlider.value)
}
}
// Global Variable ******
var slider = 0
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
if slider == 0 {
return self.line.count
} else {
return self.linefilter.count
}
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
let cell = self.tableView.dequeueReusableCellWithIdentifier("cell") as! myTableViewCell
if slider == 0 {
cell.myCellLabel.text = line[indexPath.row]
} else {
cell.myCellLabel.text = linefilter[indexPath.row]
}
cell.myImageView.image = UIImage(named: img[indexPath.row])
return cell
}
tableView.reloadata()
您好,感謝但沒有我很幸運也在幾個地方重新加載。 – jimL
我看不到你的過濾代碼,在調用reloadData()之後,你檢查代碼是否進入cell.myCellLabel.text = linefilter [indexPath.row]或cell.myCellLabel.text = line [indexPath.row]? –
發現了一個問題,在if - else代碼中,當滑塊更改值時,滑塊值不會更新,它將保留初始值0.過濾器代碼在moveSlider操作中調用,但代碼太多會隱藏故障。 – jimL