Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.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
Iphone 在UIScrollView内部,点击手势识别器不适用于UIWebView,它位于UIView内部_Iphone_Ios_Ipad_Ios5_Ios4 - Fatal编程技术网

Iphone 在UIScrollView内部,点击手势识别器不适用于UIWebView,它位于UIView内部

Iphone 在UIScrollView内部,点击手势识别器不适用于UIWebView,它位于UIView内部,iphone,ios,ipad,ios5,ios4,Iphone,Ios,Ipad,Ios5,Ios4,我将WebView放置在Scrollview中,而Scrollview又放置在viewcontroller的视图中。 点击webview时,不会调用“TapRecognited”方法 这是我的密码: UITapGestureRecognizer *oneFingerTwoTaps = [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized)] autoreleas

我将WebView放置在Scrollview中,而Scrollview又放置在viewcontroller的视图中。 点击webview时,不会调用“TapRecognited”方法

这是我的密码:

    UITapGestureRecognizer *oneFingerTwoTaps = 
      [[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapRecognized)] autorelease];

    [oneFingerTwoTaps setNumberOfTapsRequired:1];


// Add the gesture to the view

[[self view] addGestureRecognizer:oneFingerTwoTaps];
我也试过使用foll:

[scrollview addGestureRecognizer:oneFingerTwoTaps];

[webview addGestureRecognizer:oneFingerTwoTaps];

请帮助

尝试添加以下语句:

//.h
...
@interface yourclass <UIGestureRecognizerDelegate>
...

//.m
...
[oneFingerTwoTaps setDelegate:self];
...

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    return YES;
}
/.h
...
@接口你的类
...
//m
...
[oneFingerTwoTaps setDelegate:self];
...
-(BOOL)手势识别器:(UIGestureRecognizer*)手势识别器应与gestureRecognizer:(UIGestureRecognizer*)其他手势识别器同时识别{
返回YES;
}

我希望它能有所帮助

手势识别器只能添加到单个视图中。视图不能共享手势识别器。虽然UIView可以连接多个手势识别器,但UIGestureRecognitor只能连接一个视图。以下是将手势添加到任何基于UIView的视图时在UIGestureRecognitor上设置的属性

view
The view the gesture recognizer is attached to. (read-only)

@property(nonatomic, readonly) UIView *view

Discussion
 You attach (or add) a gesture recognizer to a UIView object using the addGestureRecognizer: method.

Availability
 Available in iOS 3.2 and later.
Declared In
 UIGestureRecognizer.h

谢谢你解决了我的问题,但又出现了另一个问题。在scrollview中,我有文本字段和按钮,当它们被点击时,我不希望这个手势适用于它们。我应该为tht做什么?如果您希望事件仅由webview触发,请添加webview TapRecognizer,因此不应与按钮交互。。。等