如何禁用 ImageCheckRow
How to disable an ImageCheckRow
几天来我一直在为这个问题苦苦挣扎。我有一个 ImageCheckRow 类型列表,我想将它们标记为已选中或未选中,然后禁用它们,以便用户无法更改它们。
我正在执行以下代码:
let multi = subvalue.extractBool("multi", ifnil: false)
let disableEntry = subvalue.extractBool("disabled", ifnil: false)
let title: String! = subvalue.extractString("title", ifnil: "Select")
let defaultValues = subvalue.extractNSDictionary("values");
let imageChecked: String!
let imageUnchecked: String!
if (multi)! {
currentSection = SelectableSection<ImageCheckRow<String>>(title, selectionType: .multipleSelection)
imageChecked = "images/checkbox-checked"
imageUnchecked = "images/checkbox-unchecked"
} else {
currentSection = SelectableSection<ImageCheckRow<String>>(title, selectionType: .singleSelection(enableDeselection: true))
// We should change these to radios at some point
imageChecked = "images/radio-checked"
imageUnchecked = "images/radio-unchecked"
}
form +++ currentSection!
if let options = subvalue.extractArray("options") {
for option in options {
for (optionKey, optionValue) in option as! NSDictionary {
currentSection! <<< ImageCheckRow<String> { row in
row.tag = "\(tagname)_\(optionKey)"
row.title = optionValue as? String
row.selectableValue = optionKey as? String
if let dvkey = optionKey as? String {
if let _ = defaultValues?.value(forKey: dvkey) {
row.value = optionKey as? String
}
}
row.disabled = Condition(booleanLiteral: disableEntry!)
row.evaluateDisabled()
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: imageChecked)!
cell.falseImage = UIImage(named: imageUnchecked)!
}
}
}
}
当'disableEntry'为真时,ImageCheckRow对于点击仍然有效,图像从选中变为未选中,反之亦然。我应该如何禁用这些行?
尝试指向 master 中的最新提交。
这是 Eureka 中的一个问题,在 3.0.0
发布后得到解决。它已在 PR #1063 https://github.com/xmartlabs/Eureka/pull/1063
中解决
几天来我一直在为这个问题苦苦挣扎。我有一个 ImageCheckRow 类型列表,我想将它们标记为已选中或未选中,然后禁用它们,以便用户无法更改它们。 我正在执行以下代码:
let multi = subvalue.extractBool("multi", ifnil: false)
let disableEntry = subvalue.extractBool("disabled", ifnil: false)
let title: String! = subvalue.extractString("title", ifnil: "Select")
let defaultValues = subvalue.extractNSDictionary("values");
let imageChecked: String!
let imageUnchecked: String!
if (multi)! {
currentSection = SelectableSection<ImageCheckRow<String>>(title, selectionType: .multipleSelection)
imageChecked = "images/checkbox-checked"
imageUnchecked = "images/checkbox-unchecked"
} else {
currentSection = SelectableSection<ImageCheckRow<String>>(title, selectionType: .singleSelection(enableDeselection: true))
// We should change these to radios at some point
imageChecked = "images/radio-checked"
imageUnchecked = "images/radio-unchecked"
}
form +++ currentSection!
if let options = subvalue.extractArray("options") {
for option in options {
for (optionKey, optionValue) in option as! NSDictionary {
currentSection! <<< ImageCheckRow<String> { row in
row.tag = "\(tagname)_\(optionKey)"
row.title = optionValue as? String
row.selectableValue = optionKey as? String
if let dvkey = optionKey as? String {
if let _ = defaultValues?.value(forKey: dvkey) {
row.value = optionKey as? String
}
}
row.disabled = Condition(booleanLiteral: disableEntry!)
row.evaluateDisabled()
}.cellSetup { cell, _ in
cell.trueImage = UIImage(named: imageChecked)!
cell.falseImage = UIImage(named: imageUnchecked)!
}
}
}
}
当'disableEntry'为真时,ImageCheckRow对于点击仍然有效,图像从选中变为未选中,反之亦然。我应该如何禁用这些行?
尝试指向 master 中的最新提交。
这是 Eureka 中的一个问题,在 3.0.0
发布后得到解决。它已在 PR #1063 https://github.com/xmartlabs/Eureka/pull/1063