Ios 在滚动条视图中未检测到触摸位置

Ios 在滚动条视图中未检测到触摸位置,ios,swift,location,touch,Ios,Swift,Location,Touch,我正在尝试将图像从滚动视图移动到屏幕上的其他点。当我触摸滚动条视图(名为optionScroller)外部时,它会工作,但在滚动条视图内部未检测到任何内容: override func touchesEnded(touches: Set<UITouch>, withEvent: UIEvent?) { self.movingImageView.image = nil } override func touchesBegan(touches: Set<UIT

我正在尝试将图像从滚动视图移动到屏幕上的其他点。当我触摸滚动条视图(名为optionScroller)外部时,它会工作,但在滚动条视图内部未检测到任何内容:

override func touchesEnded(touches: Set<UITouch>, withEvent: UIEvent?) {
    self.movingImageView.image = nil


    }

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
    for touch in (touches ){

        location = touch.locationInView(view)

        movingImageView.center = location

    }}

override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
    for touch in (touches ){

        location = touch.locationInView(self.view)

        movingImageView.center = location

}}
override func touchesend(touch:Set,withEvent:UIEvent?){
self.movingImageView.image=nil
}
覆盖功能触摸开始(触摸:设置,withEvent事件:UIEvent?){
用于触摸输入(触摸){
位置=触摸。位置查看(视图)
movingImageView.center=位置
}}
覆盖功能触摸移动(触摸:设置,带事件:UIEvent?){
用于触摸输入(触摸){
位置=touch.locationInView(self.view)
movingImageView.center=位置
}}

你试过使用hitTest吗?Eric Small,一件简单的事情要看,你不需要使用for循环撕开触摸集,你只需要这样做:-(void)touchesStart:(NSSet*)touchs with event:(UIEvent*)event{UITouch*touch=event.alltouch.anyObject;CGPoint touchLocation=[touch locationInView:[self-contentView]];if(CGRectContainsPoint(_-nahd.frame,touchLocation)| | CGRectContainsPoint(_-certSelect.frame,touchLocation)){[super-touchsbegind:touchswithevent:event];}否则{return;}这是objective-C,这不会解决您的问题,但只会解决您的问题我想我回答了我自己的问题。我必须将滚动视图中的触摸位置转换为视图:locationRelativeToScreen=option1InsertImageView.convertPoint(位置,toView:view)你试过使用hitTest吗?Eric Small,一个简单的例子,你不需要使用for循环撕开触摸集,你只需要这样做:-(void)touchesBegind:(NSSet*)toucheEvent:(UIEvent*)event{UITouch*touch=event.allTouchs.anyObject;CGPoint touchLocation=[touchLocationInView:[self-contentView]];if(CGRectContainsPoint(_-nahd.frame,touchLocation)| | CGRectContainsPoint(_-certSelect.frame,touchLocation)){[super-touchsbegind:touchswithevent:event];}否则{return;}这是objective-C,这不会解决您的问题,但只会解决您的问题我想我回答了我自己的问题。我必须将滚动视图中的触摸位置转换为视图:locationRelativeToScreen=option1InsertImageView.convertPoint(位置,toView:view)