使用控件来指示变量的设置位置
我刚刚开始,仍在努力改进我的小扑克计算器。我的目标是让右侧的控件(绿色)设置中间文本框的浮点值。问题是我只想对红色箭头所在的文本框执行此操作。另一方面,如果我移动红色箭头,我希望它将绿色箭头重置为红色停止的文本框中的任何内容。
希望这是有道理的。
我对所有滑块都有操作方法,红色根据停止位置准确返回 1-8 之间的值(当前为 1)
文本框暂时全部命名为 call_1、call_2 等,但我不知道如何制作除了我需要的名称之外的任何内容的方法声明。因为红色箭头返回 1-8,所以 _1、_2 等将是正确的选择。在一些地方也使用这个 for 循环计数也很好。
http://img833.imageshack.us/i/screenshot20110319at723.png/
谢谢大家,我真的非常感谢 Overflow 迄今为止所做的一切!
欢呼
格雷厄姆
编辑:
我想做的是使用文本框使用红色滑块,它以这种方式给我一个 X (1-8) 的整数。
[call_x setFloatValue:someValue]
当 X 改变时,目的地也会改变。如果我能得到这方面的帮助,我就可以操纵它来做我想做的一切。
I'm just starting out, still working on improving my little poker calculator. What I'm aiming to do is have the controls on the right (green) set the float value of the middle textboxes. The hitch is that I want to do it to only the textbox that the red arrow is at. On the flipside if I move the red arrow I want it to reset the green arrow to whatever is in the textboxes where red stops.
Hope that makes sense.
I have action methods for all of the sliders and red returns exactly a value from 1-8 depending on where it stops (Currently 1)
The textboxes are all named call_1, call_2 etc for the time being but I don't know how make a method declaration for anything but exactly the name I need. Because the Red Arrow returns 1-8 that _1, _2 etc would be the way to go. It would also be nice to use this for loop counts as well in a few places.
http://img833.imageshack.us/i/screenshot20110319at723.png/
Thanks guys, I really really appreciate everything Overflow has done so far!
Cheers
Graham
Edit :
What I am trying to do is with the textboxes is to use the red slider which gives me an int of X (1-8) in this fashion.
[call_x setFloatValue:someValue]
As X changes the destination changes as well. If I can get help with this I can manipulate it to do everything else I want.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全理解您想要完成的任务,但通过查看您的屏幕截图,我敢打赌键值观察可以帮助您。看起来您正在处理大量的粘合代码,最终使控制器类变得混乱。当视图更改时,此粘合代码会管理更新模型,反之亦然。它还定义视图之间的逻辑(即当滑块更改等时更新文本框)。
http://developer.apple.com/library/ ios/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html
键值观察允许您在另一个对象中的某些值发生更改时接收回调。在此回调中,您可以更新任何其他需要它的内容。更进一步的是可可中的结合。绑定实际上是将一个对象的属性绑定到另一个对象的值。您应该研究这些技术,以减少您必须自己管理的无聊粘合代码的数量。
I don't fully understand what you are trying to accomplish but from looking at your screenshot I would bet that key-value observing could help you. It looks like you are dealing with the copious amounts of glue code that ends up cluttering up controller classes. This glue code manages updating your model when a view changes, and vice versa. It also defines the logic among views (i.e update a text box when a slider changes etc).
http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/KeyValueObserving/KeyValueObserving.html
Key-Value observing allows you to receive a callback when some value in another object changes. In this callback you update anything else that needs it. Taking this one step further is bindings in cocoa. Bindings literally bind the property of one object to the value of another. You should investigate these technologies to reduce the amount of boring glue code you have to manage yourself.