我的第一个iOS应用程序使用简单的自定义单元格,但是过滤tableView行的增强导致了延迟和挫折。在网上搜索有关过滤行的帮助,阅读苹果开发人员指南中的dataSource和委托协议,到目前为止还没有成功。
使用滑块值刷新表行。从线阵列(100个项目)提取数据到linefilter阵列(20)。然后想要刷新/重新加载表视图。
Slider被声明为0,并且所有行数组项目都会显示出来。移动滑块不会改变显示。如果将slider声明为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()发布于 2016-08-03 03:24:02
试着把
tableView.reloadData() 像这样
let slider = Int(lineSlider.value)
tableView.reloadData()
}在moveSlider函数中
https://stackoverflow.com/questions/38728606
复制相似问题