1

一切都在我的代码中运行,但我总是收到“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....
}
4

2 回答 2

6

关于线路:

swipeLeft.delegate =  self;

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

@interface viewCont : UIViewController<UIGestureRecognizerDelegate> {

}

@end

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

于 2012-02-20T12:17:49.307 回答
0

这个类是 UIWebView 的子类吗?

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

于 2012-07-25T00:33:40.633 回答