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