ios - 根据 MultipleSelectorRow 的值启用/禁用行

标签 ios swift swift2 eureka-forms

这是一个与名为 Eureka 的 Swift 开源项目相关的问题。我在这里发布这个问题,因为他们在这里监控他们的标签。

我创建了一个表单,其中包含一个 MultipleSelectorRow 和一个 TextRow。该 TextRow 默认情况下处于禁用状态。 MultipleSelectorRow 显示选项列表。

form
    +++ Section()
    <<< MultipleSelectorRow<String>("Lead") {
        $0.title = "Lead"
        $0.options = ["Yahoo", "Yelp", "Google", "Referral or Other"]
    }
    .onPresent { from, to in
        to.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .Done, target: from, action: #selector(ViewController.multipleSelectorDone(_:)))
    }
    <<< TextRow("Referral") {
        $0.title = "Note Referral or Other"
        $0.disabled = "$Lead != 'Referral or Other'"
    }

我想要的是,如果用户选择最后一个选项,推荐或其他,我希望启用 TextRow

我当前的上述实现并没有做到这一点。它保持禁用状态。我在这里做错了什么?

最佳答案

根据定义MultipleSelectorRow<T>持有Set<T>作为值类型,并且您似乎错误地期望 String 值。

话虽如此,您应该尝试使用这个谓词......

$0.disabled = "NOT $Lead contains 'Referral or Other'"

或者..

$0.hidden = Condition.Function(["Lead"]) { form in
        if let r1 : MultipleSelectorRow <String> = form?.rowByTag("tag1") {
            return r1.value.contains("Referral or Other") == false
        }
        return false
}

关于ios - 根据 MultipleSelectorRow 的值启用/禁用行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36361200/

相关文章:

ios - UISplitViewController - 在主视图 Controller 中点击单元格会导致在主视图 Controller 中出现 segue,而不是在详细 View Controller 中

ios - 如何使用委托(delegate)将变量传递给另一个 View Controller

swift - Swift 中嵌套可选类型及其数组的推断、静态和动态类型

ios - Tableview 中的文本字段在 iOS 9 和 iOS10 上的行为有所不同

ios - Cocoa 中文件的内容修改日期

android - InAppPurchase ios 电话间隙

swift - 当dispatch_async(dispatch_get_main_queue())运行时如何从类方法发送信息

ios - 旋转设备时,动画 uiview 切换回其原始状态

swift - NSInternalInconsistencyException',原因: 'unable to dequeue a cell with identifier MealTableViewCell - must register a nib

ios - UIWebView for GIF 后台loadData方法报错