Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 阻止iPad Safari上的所有默认手势_Javascript_Ios_Safari_Gestures - Fatal编程技术网

Javascript 阻止iPad Safari上的所有默认手势

Javascript 阻止iPad Safari上的所有默认手势,javascript,ios,safari,gestures,Javascript,Ios,Safari,Gestures,如何在iPad上使用纯javascript禁用Safari上的所有默认手势。 我尝试过使用event.preventDefault()针对每个事件,但它不起作用。 我在Safari中运行应用程序,我想禁用所有默认触摸事件(手势),并用我自己的覆盖。我还尝试使用一个流行的库hammer.js,它有一个选项prevent\u default,但不起作用。我认为你的问题不够清楚(请更改它)。你的意思是你有一个iOS应用程序和一个UIWebView,你想禁用该UIWebView上的所有鼠标交互吗?如果是

如何在iPad上使用纯javascript禁用Safari上的所有默认手势。 我尝试过使用
event.preventDefault()针对每个事件,但它不起作用。

我在Safari中运行应用程序,我想禁用所有默认触摸事件(手势),并用我自己的覆盖。我还尝试使用一个流行的库hammer.js,它有一个选项prevent\u default,但不起作用。

我认为你的问题不够清楚(请更改它)。你的意思是你有一个iOS应用程序和一个UIWebView,你想禁用该UIWebView上的所有鼠标交互吗?如果是这样的话,那么您确实必须禁用滚动,例如:

<script type="text/javascript">
touchMove = function(event) {
    event.preventDefault();
}
</script>
在项目中添加通配符GestureRecognitzerForwarder.h,代码如下:

    #import <Foundation/Foundation.h>

typedef void (^TouchesEventBlock)(NSSet * touches, UIEvent * event);

@interface WildcardGestureRecognizerForwarder : UIGestureRecognizer

@property(nonatomic,assign) UIView *forwardFrom;
@property(nonatomic,assign) UIViewController *forwardTo;

-(void) initWithController:(UIViewController*)theViewController andView:(UIView*)theView;
@end
#import "WildcardGestureRecognizerForwarder.h"

@implementation WildcardGestureRecognizerForwarder

-(id) init {
    if (self = [super init])
    {
        self.cancelsTouchesInView = NO;
    }
    return self;
}

-(void) initWithController:(id)theViewController andView:(UIView*)theView {
    if ([self init]) {
        self.forwardFrom = theView;
        self.forwardTo = theViewController;
        [theView addGestureRecognizer:self];
        self.delegate = theViewController;
    }
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    if(self.forwardTo)
        [self.forwardTo touchesBegan:touches withEvent:event];
}

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
    if(self.forwardTo)
        [self.forwardTo touchesCancelled:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    if(self.forwardTo)
        [self.forwardTo touchesEnded:touches withEvent:event];
}

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    if(self.forwardTo)
        [self.forwardTo touchesMoved:touches withEvent:event];
}

- (void)reset
{
}

- (void)ignoreTouch:(UITouch *)touch forEvent:(UIEvent *)event
{
}

- (BOOL)canBePreventedByGestureRecognizer:(UIGestureRecognizer *)preventingGestureRecognizer
{
    return NO;
}

- (BOOL)canPreventGestureRecognizer:(UIGestureRecognizer *)preventedGestureRecognizer
{
    return NO;
}

@end
预防阴囊:

document.ontouchmove = function(event){
event.preventDefault();}
防止抽头:

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>


您为什么要这样做?除了烦扰用户之外,还有什么别的原因吗?因为我有一个应用程序,比如说,当我想拖动我的对象时,Safari拖拽会让我烦恼吗?它会让你烦恼吗?您希望自己能够在javascript中做得更好吗?这似乎是个坏主意™ 对我来说,我想你不理解我。例如我有一个画布,在那里我对图像执行操作。如果我想拖动图片,这是不可能的,因为浏览器拖动的是图片而不是图片。你明白吗?对不起,解释得不好。你找到这个问题的解决方案了吗?我也遇到了同样的问题。我会在找到解决方案后再补充。
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/>