Multiple DCSliders sending different control values (Xcode)(多个 DCSlider 发送不同的控制值(Xcode))
问题描述
这个问题可能非常具体,但我是新手,真的需要一些帮助.
This question may be very specific, but I'm new to all this and really need some help.
我正在构建一个 iPhone 合成器应用.我正在使用 DCSliders 和 DCKnobs(它们看起来比标准 UISliders 更好).
I'm building an iPhone synth app. I am using DCSliders an DCKnobs (they look nicer than the standard UISliders).
https://github.com/domesticcatsoftware/DCControls#readme
我也在使用 libpd(一个 Pure Data 库),因此音频 DSP 由嵌入式 Pure Data 补丁处理.
I am also working with libpd (a Pure Data library) so the audio DSP is handled by an embedded Pure Data patch.
https://gitorious.org/pdlib
我的界面中有多个 DCSlider 和 DCKnobs.我可以通过将类设置为 DCSlider 的委托,将控制值从滑块/旋钮发送到 Pure Data...
I have got multiple DCSliders and DCKnobs in my interface. I am able to send control values from the sliders/knobs to Pure Data by making a class the delegate of the DCSlider...
- (void)loadView {
[super loadView];
self.mySlider = [[[DCSlider alloc] initWithDelegate:self] autorelease];
self.mySlider.frame = CGRectMake(10.0, 10.0, 20.0, 120.0);
[self.view addSubview:self.mySlider];
}
然后我实现了一种方法,将控制值发送到 Pure Data 中的接收器...
Then I implement a method to send control values to a receiver in Pure Data...
- (void)controlValueDidChange:(float)value sender:(id)sender {
[PdBase sendFloat:value toReceiver:@"beatvol"];
}
一切正常.
问题是所有滑块都发送相同的控制值.
The problem is that all of the sliders are sending the same control values.
如何让每个 DCSlider 将独立的控制值发送到 Pure Data 中的不同接收器?
How do I get each of the DCSliders to send independent control values to different receivers in Pure Data?
推荐答案
您需要为滑块分配一个标签.然后在 controlValueDidChange:
中,您需要获取该标签并根据标签执行您的操作:
You need to assign a tag to your sliders. Then in controlValueDidChange:
you need to get that tag and do your actions according to the tags:
- (void)loadView
{
[super loadView];
mySlider = [[[DCSlider alloc] initWithDelegate:self] autorelease];
mySlider.frame = CGRectMake(10.0, 10.0, 20.0, 120.0);
mySlider.tag = 0;
[self.view addSubview: mySlider];
}
- (void)controlValueDidChange:(float)value sender:(id)sender
{
DCSlider * slider = (DCSlider *)sender;
switch (slider.tag)
{
case 0:
{
[PdBase sendFloat:value toReceiver:@"beatvol"];
}
break;
case 1:
{
/* do something for the 2nd slider */;
}
break;
}
}
这篇关于多个 DCSlider 发送不同的控制值(Xcode)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:多个 DCSlider 发送不同的控制值(Xcode)


- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01