我有这样的代码,它是在iOS的Swift 4中制作的。
它是如何工作的?很简单-我在dataCore中有一些数据,并且这段代码将这些数据提取到表格视图中。
我的问题是什么? -它的工作原理很完美,但是当我选择一行时,应用程序会向我显示“已选择一行...等等”,这还可以,但是当我查看应用程序时,我已经“检查”了每一行。
@IBAction func licenseSelection(_ sender: Any) {
let context = licenseSavingController.persistentContainer.viewContext
let request = NSFetchRequest<NSFetchRequestResult>(entityName: "Licencja")
let selectionMenu = RSSelectionMenu(selectionType: .Single, dataSource: licencje, cellType: .Basic) { (cell, object, indexPath) in
cell.tintColor = .orange
request.returnsObjectsAsFaults = false
do {
var result = try context.fetch(request) as! [NSManagedObject]
result = [result[indexPath.row]]
for data in result {
self.licznik = self.licznik+1
cell.textLabel?.text = data.value(forKey: "licenseDescript") as? String ?? data.value(forKey: "licenseURL") as? String
//forKey: "licenseURL") as? String ?? "default"
//forKey: "licenseNumber") as? String ?? "default"
//data.value(forKey: "deviceID") as? String ?? "default"
}
} catch {
print("Failed")
}
}
selectionMenu.uniquePropertyName = "licznik"
selectionMenu.setSelectedItems(items: wybranaLicencja) { (text, isSelected, selectedItems) in
self.wybranaLicencja = selectedItems
print(selectedItems)
}
selectionMenu.show(style: .Popover(sourceView: sender as! UIView, size: nil), from: self)
}
像这样: https://imgur.com/nveTKJ8 我真的很困惑:P