【问题标题】:UIWebView Swipe-GestureUIWebView 滑动手势
【发布时间】:2012-01-31 11:38:30
【问题描述】:

我的代码中一切正常,但我总是收到“swipeLeft.delegate = self;”的警告

这个警告标记了“自我”。

警告是:将'UIWebView *'传递给不兼容类型的参数

将“viewCont *const __strong”传递给不兼容类型“id UIGestureRecognizerDelegate”的参数

我能做什么??

我的代码:

#import "viewCont.h"

@implementation viewCont

@synthesize webView = webView_;

- (void)viewDidLoad
{
//...code

// add Left 
    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeLeftAction:)];
    swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
    swipeLeft.delegate =  self;
    [webView_ addGestureRecognizer:swipeLeft];

//code....
}

【问题讨论】:

    标签: xcode uiwebview swipe-gesture uiswipegesturerecognizer


    【解决方案1】:

    关于线路:

    swipeLeft.delegate =  self;
    

    您的控制器需要实现 UIGestureRecognizerDelegate,如下所示:

    @interface viewCont : UIViewController<UIGestureRecognizerDelegate> {
    
    }
    
    @end
    

    我在提供的代码中没有看到任何关于 webView 警告的问题代码。

    【讨论】:

      【解决方案2】:

      这个类是 UIWebView 的子类吗?

      您将目标设置为 self,请确保该对象是 UIWebView 的实例或子类。如果您将 WebView 设置为实例变量,则需要将手势识别器的目标设置为该实例。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多