小编ins*_*ing的帖子

禁用 UIButton 不起作用

我在这里找到的解决方案使用的.enabled是旧的,而不是.isEnabled.

因此,如果满足(或不满足)某个条件,我正在尝试仅禁用按钮的功能/可点击性。所以在这一切之前,如果不满足条件,我将它们全部禁用,然后如果在(动态)之后满足它,那么理论上应该启用。话虽如此,当我从.isEnabled = false.

我知道满足条件是因为我有打印语句和其他测试(比如标签从超级视图中删除但.isEnabled = false按钮不起作用。有人遇到过上述问题或有任何解决方案吗?

代码如下:

override func viewDidLoad()
{
    super.viewDidLoad()
    trumpMoneyDefault.setValue(50, forKey: "TrumpMoney")
    print("UnoViewController")
    //make all the buttons that shouldn't be clickable unlcickable
    locklvl2.isEnabled = false
    locklvl3.isEnabled = false
    trumplvl2.isEnabled = false
    trumplvl3.isEnabled = false
    lvl2.isEnabled = false
    lvl3.isEnabled = false

    //make level2/3 unclickable by defeault
    //lvl2.isEnabled = false
    //lvl3.isEnabled = false
    //update trumpmoney label depending on if they have enough cash
    //also here check if they have already …
Run Code Online (Sandbox Code Playgroud)

uibutton uiview isenabled swift

5
推荐指数
1
解决办法
5195
查看次数

'DocumentData | 类型的参数 undefined' 不可分配给类型为 'DocumentData' 的参数

首先,我想说我的很多代码可能很糟糕,所以我很抱歉。我的 .ts 和 .js 经验并不是让我感到非常舒服的时候(因此我无法解决这个问题)。所以我试图将文档内容从一个文档获取到另一个文档。目前是通过快照来完成的,但我确信有更快更好的方法。我的代码如下。

当我尝试将第二个集合 (redacted2) 的文档设置为快照数据时,会发生错误。正如您从控制台日志中可以看出的,我知道 snapshot.data() 具有我需要的有价值的信息,我需要完全按照我希望的方式对其进行格式化。我假设这类似于在 swift 中有一个保护语句,我可以在其中检查 null 的值并将其分配给给定的类型(但我在这里可能是错的)。

                db.collection("Redacted").doc(context.params.sensors).get()
                .then(function(querySnapshot){
                    console.log("Query Snapshot is is isssss: ", querySnapshot)
                    console.log("Query Snapshot querySnapshot.data: ", querySnapshot.data)
                    console.log("Query Snapshot querySnapshot.data(): ", querySnapshot.data())
                    console.log("Query Snapshot querySnapshot.ref: ", querySnapshot.ref)
                    console.log("Query Snapshot querySnapshot.get: ", querySnapshot.get)

                    return querySnapshot
                }).then(function(querySnapshotData) {
                    console.log("ayoooooo blooooddd", querySnapshotData)
                    db.collection("Redacted2").doc(context.params.sensors).set(querySnapshotData.data())
                        .then((alertResponse1: any) => {
                            console.log("Successfully updated firestore: ", alertResponse1)
                        })
                        .catch ((alertError1: any) => {
                            console.log("Successfully updated firestore but with error: ", alertError1)
                        })
                })
                .catch(function(error) {
                    console.log("query snapshot …
Run Code Online (Sandbox Code Playgroud)

typescript google-cloud-functions google-cloud-firestore

0
推荐指数
1
解决办法
1495
查看次数