【问题标题】:UIWebView touches, gestures not workingUIWebView 触摸,手势不起作用
【发布时间】:2014-02-05 08:33:52
【问题描述】:

如果我像这样加载 Web 视图的内容,UIWebView 触摸、手势不起作用

NSString* htmlPath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"source.bundle/index.html"];

NSURL* url = [NSURL fileURLWithPath:htmlPath];
NSLog(@"the urll==%@",url);

NSURLRequest* request = [NSURLRequest requestWithURL:url];
[self.webView loadRequest:request];

UIPanGestureRecognizer *recognizer =[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panDetected:)];

[self.webView addGestureRecognizer:recognizer];

【问题讨论】:

  • 请展示你如何实现你的功能panDetected:
  • 你能显示你的 panDetected: 方法
  • 您是否将UIGestureRecognizerDelegate 添加到您的控制器?然后将recognizer.delegate设置为你的panDetected:方法实现的控制器

标签: ios iphone objective-c uiwebview


【解决方案1】:

你好,你可以试试这个,

UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc]
    initWithTarget:self action:@selector(panSubview:)];
[subview addGestureRecognizer:panRecognizer];

// play nice with subview's pan gesture
[YourView.panGestureRecognizer 
    requireGestureRecognizerToFail:panRecognizer];

谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多