移动滑块控件时尝试找出我的触摸位置
我想在 iPhone 上创建一个变速滑块控件。 基本上我使用的是 UISlider 控件,但我想通过检测手指在当前视图中的位置来向该控件添加第二个维度。
EG 用户可以左右滑动控件,但我想查看他们的手指在视图中的垂直位置。
我的问题是当您操纵滑块控件时。 不调用以下函数。
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
所以这意味着我无法检测到任何触摸事件,因为我假设它们被发送到滑块? 有人尝试这样做吗? 或者我应该将 UISlider 子类化。 嗯。
I would like to create a variable speed slider control on the iPhone.
Basically I am using a UISlider control but I would like to add a second dimension to this control by detecting where the finger is in the current view.
E.G. A user can slide the control left and right, but I want to see where their finger is vertically in the view.
My issue is that when you are manipulating a slider control.
The following function is not called.
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
so this means I cannot detect any touch events because I assume they are being sent to the slider? Anyone tried to do this? Or should I sub class UISlider. Hmmm.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
标头
主文件
导入“JBSlider.h”@implementation
JBSlider
@synthesizeverticalTouchDelta;
- (void)sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event{
[super sendAction:action to:target forEvent:事件];
//NSLog(@"HI HI");
@end
。
只需在 Interface Builder 中将滑块从 UISlider 更改为 JBSlider 即可
效果棒极了。
header
main file
import "JBSlider.h"
@implementation JBSlider
@synthesize verticalTouchDelta;
- (void)sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event{
[super sendAction:action to:target forEvent:event];
//NSLog(@"HI HI");
}
@end
Simply change your slider from UISlider to JBSlider in Interface Builder.
Works awesome.