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)


基础教程推荐
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01