【发布时间】:2016-08-03 06:44:51
【问题描述】:
我的第一个 iOS 应用程序使用简单的自定义单元格,但过滤 tableView 行的增强会导致延迟和挫败感。在线搜索有关过滤行的帮助,阅读 Apple 开发人员指南中的数据源和委托协议,目前没有运气。
使用滑块值刷新表格行。从线阵列(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()
【问题讨论】:
标签: ios swift filter tableview