[英]Filter tableView rows doesn't reload tableView
我的第一個iOS應用程序使用簡單的自定義單元格,但是增強對tableView行的篩選功能會導致延遲和沮喪。 在線搜索有關過濾器行的幫助,閱讀Apple Developer指南中的dataSource和委托協議,到目前為止沒有任何運氣。
使用滑塊值刷新表行。 從行數組(100個項目)中提取數據到行linefilter
數組(20)。 然后要刷新/重新加載tableview。
將Slider聲明為0,並顯示所有行數組項。 移動滑塊不會改變顯示。 如果用1聲明滑塊,則顯示20個過濾器項。
對於Apple / Xcode / Swift來說是相當新的知識,所以沒有Objective C知識。
任何答案都可能會幫助我到達那里。 吉姆·L
相關代碼選擇:
@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()
嘗試把
tableView.reloadData()
像這樣
let slider = Int(lineSlider.value)
tableView.reloadData()
}
在您的moveSlider函數中
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.