迭代Firebase阵列(Iterating Through Firebase Array)
当我得到数据库的快照时,我看到了这个:
{ "9-17-2017" = { "19:26:38" = { 1abA = 1ab; 1abrA = 1; 2abA = 2ab; 2abrA = 2; 3abA = 3ab; 4abA = 4ab; 5abA = 5a; 6abA = 6ab; 7abA = 7ab; Date = "9-17-2017"; Time = "19:26:38"; anA = an; apnA = apn; q1A = 1; q2A = 2; q3A = 3; q4A = 4; q5A = 5; q6A = 6; }; "20:16:15" = { 1abA = 1qwe; 1abrA = 3; 2abA = "D.C."; 2abrA = 7; 3abA = wedded; 4abA = wedge; 5abA = qdwfeg; 6abA = qwfegr; 7abA = wedge; Date = "9-17-2017"; Time = "20:16:15"; anA = "we're"; apnA = apn; q1A = 7; q2A = 2; q3A = 7; q4A = 4; q5A = 5; q6A = 7; }; }; }
我希望能够将标签设置为键1abA的值,但我似乎无法找到一种方法来对数组进行排序。
我正在使用此代码来获取快照:
let userID = Auth.auth().currentUser?.uid let ref = Database.database().reference().child("users").child(userID!) ref.child("PostGameEval").observe(.value, with: { (snapshot) in print(snapshot.value!) })
When I get a snapshot of the database I see this:
{ "9-17-2017" = { "19:26:38" = { 1abA = 1ab; 1abrA = 1; 2abA = 2ab; 2abrA = 2; 3abA = 3ab; 4abA = 4ab; 5abA = 5a; 6abA = 6ab; 7abA = 7ab; Date = "9-17-2017"; Time = "19:26:38"; anA = an; apnA = apn; q1A = 1; q2A = 2; q3A = 3; q4A = 4; q5A = 5; q6A = 6; }; "20:16:15" = { 1abA = 1qwe; 1abrA = 3; 2abA = "D.C."; 2abrA = 7; 3abA = wedded; 4abA = wedge; 5abA = qdwfeg; 6abA = qwfegr; 7abA = wedge; Date = "9-17-2017"; Time = "20:16:15"; anA = "we're"; apnA = apn; q1A = 7; q2A = 2; q3A = 7; q4A = 4; q5A = 5; q6A = 7; }; }; }
I want to be able to set a label to the value of the key 1abA but I can't seem to figure out a way to sort through the array.
I am using this code to get the snapshot:
let userID = Auth.auth().currentUser?.uid let ref = Database.database().reference().child("users").child(userID!) ref.child("PostGameEval").observe(.value, with: { (snapshot) in print(snapshot.value!) })
原文:https://stackoverflow.com/questions/46270028
更新时间:2024-01-14 17:01
最满意答案
如文档所述,您应该等到视图附加到窗口后再开始动画。 因此,您应该将OnAttachStateChangeListener添加到将在附加时执行的视图,并从那里开始动画。
ImageView img = (ImageView)v.findViewById(R.id.image); img.setBackgroundResource(R.drawable.anim); img.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener() { @Override public void onViewAttachedToWindow(View v) { AnimationDrawable animation = (AnimationDrawable) v.getBackground(); animation .start(); } @Override public void onViewDetachedFromWindow(View v) { } });
i have found my problem !
i had used GamePic.setImageResource(Resources2.GamePicArray[position]);
but i should use
GamePic.setBackgroundResource(Resources2.GamePicArray[position]);
now it works fine !
相关问答
更多-
播放动画节点不起作用(Play Animation Node not working)[2023-05-29]
为此运行你的网格动画类应该设置为none for this to run your mesh's animation class should be set to none -
调用clearAnimation() , View您调用的startAnimation() 。 Call clearAnimation() on whichever View you called startAnimation().
-
你的代码看起来不错。 您可以运行以下代码以查看它是否正常工作: fade-in { opacity:0; -webkit-animation:fadeIn ease-in 1; -moz-animation:fadeIn ease-in 1; animation:fadeIn ease-in 1; -webkit-animation-fill-mode:forwards; -moz-animation-fill-mode:forwards ...
-
动画中的动画不起作用(animation in animation doesnt work)[2023-09-06]
如果我错了,请纠正我,但我看到你试图在image1内部step启动动画的唯一原因是因为你希望它在image2动画中途完成时启动。 由于您已定义动画持续时间,因此可以使用简单的$.delay : function startAnimation() { $(".slide div.image2") .animate({left: wWidth / 4, opacity: 1}, 1800) .animate({left: -wWidth, opacity: 0}, 100 ... -
可绘制的动画不起作用(drawable animation not workin)[2022-08-10]
如文档所述,您应该等到视图附加到窗口后再开始动画。 因此,您应该将OnAttachStateChangeListener添加到将在附加时执行的视图,并从那里开始动画。 ImageView img = (ImageView)v.findViewById(R.id.image); img.setBackgroundResource(R.drawable.anim); img.addOnAttachStateChangeListener(new View.OnAttachStateChangeListener( ... -
在背景图像的情况下,动画不起作用。 Firefox不支持在背景图像之间进行插值。 这就解释了为什么你的代码在background-color情况下适用于所有浏览器,以及为什么在background-image情况下它不适用 请参阅此条目: https : //bugzilla.mozilla.org/show_bug.cgi? id = 1036761和http://forums.mozillazine.org/viewtopic.php?f=25&t=2699753 CSS: .truck-size { ...
-
查询不起作用(Query not workin)[2023-12-06]
您对此类问题进行故障排除的方法是将查询分解为多个部分,直到找到问题的根源。 有时您可能需要在连接中使用select *或指定列,或者在最终产品中未返回的where子句中查看正在进行的操作。 我会做类似下面的事情,运行每一个,直到你看到记录掉落的地方: SELECT username FROM tbl_name WHERE publishedapp = \"Mencap@Work2-1\" SELECT * FROM tbl_name WHERE username in ( SELECT ... -
为什么延迟不起作用? Less循环没有问题。 实际问题在于通过代码设置animation-delay值的方式以及它与预期值的不同之处。 根据CSS规范,对于任何时间值,数字和单位之间应该没有空格。 引用MDN : CSS数据类型表示以秒或毫秒表示的时间维度。 它们由紧随其后的单位组成。 与任何CSS维度一样,单位字面值与数字之间没有空格。 减去 - 以下是用于设置延迟值的较少代码。 animation-delay : @delay s; 编译的CSS - 编译上面的Less代码时,您将获得 ...
-
更好地使用alpha。 UIImageView *iv = self.imageView; ZGCBubbleView *bubbleView = [[ZGCBubbleView alloc] init]; bubbleView.alpha = 0; // bubbleView.hidden = YES; [iv addSubview:bubbleView]; // UIView animation test [UIView animateWithDuration:2.0 ...
-
只需添加position: relative; 你的#text div是这样的: #text { color: red; z-index: 10; background: transparent; position: relative; } 链接到jsFiddle: https ://jsfiddle.net/AndrewL32/e35xu520/3/ Just add position: relative; to your #text div like this: #te ...