Browse Source

bug fixed.

pull/1/head
gme_2 6 years ago
parent
commit
0542cc0e62
  1. 15
      GMERemittance/Library/ItemPickerView/ItemsPickerViewController.swift

15
GMERemittance/Library/ItemPickerView/ItemsPickerViewController.swift

@ -105,12 +105,15 @@ class ItemsPickerViewController: UIViewController {
self.filteredPlaces = self.data
return
}
print("searchString : \(searchString), \(filteredPlaces)")
self.filteredPlaces = self.data.filter({
return searchString.isEmpty ||
$0.lowercased().contains(searchString.lowercased())
}).sorted(by: { (a, _) -> Bool in
return (a.lowercased() ?? "").hasPrefix(searchString.lowercased())
})
print("after search")
print(filteredPlaces)
}
// MARK: IBActions
@ -158,14 +161,6 @@ extension ItemsPickerViewController: UITableViewDelegate {
let cell = tableView.cellForRow(at: indexPath)
cell?.accessoryType = .none
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let onlyIndex = data[indexPath.row].components(separatedBy: " ").first ?? ""
if defaultSelectedData.contains(onlyIndex) {
tableView.selectRow(at: indexPath, animated: false, scrollPosition: .none)
}
}
}
extension ItemsPickerViewController: UITableViewDataSource {
@ -175,12 +170,12 @@ extension ItemsPickerViewController: UITableViewDataSource {
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return data.count
return filteredPlaces.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableVIew.dequeueReusableCell(withIdentifier: "ItemsPickerCell", for: indexPath) as! ItemsPickerCell
cell.place = self.data.elementAt(index: indexPath.row)
cell.place = self.filteredPlaces.elementAt(index: indexPath.row)
if let selected = self.defaultSelectedData.first {
cell.selectedPlace = selected
}

Loading…
Cancel
Save