2012-09-30 41 views
-1

我遇到了GestureRecognizer和BlocksKit的問題,它給我一個構建錯誤。BlockKit Xcode構建錯誤的GestureRecognizer塊

基本上我想在手勢上運行一個塊。我從這裏的文件複製的代碼....

http://zwaldowski.github.com/BlocksKit/Documentation/Categories/UIGestureRecognizer(BlocksKit).html

...當我每次都收到同樣的生成錯誤到目前爲止,我沒有成功。我搜查了周圍,找不到任何與我有同樣的問題,所以我希望有人在這裏也許可以幫助。

使用的代碼IM是...

UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(id sender) { 
      NSLog(@"Single tap."); 
     } delay:0.18]; 

我收到的是錯誤...

/Users/JohnSlater/Desktop/iOS Apps/Flink/flink/ViewController.m:202:91: Incompatible block pointer types sending 'void (^)(id)' to parameter of type 'BKGestureRecognizerBlock' (aka 'void (^)(UIGestureRecognizer *, UIGestureRecognizerState, CGPoint)') 

在此先感謝

回答

2

看看塊的參數在錯誤信息中。你的代碼有一個參數,發件人。但是這個塊需要一個UIGestureRecognizer,一個UIGestureRecognizerState和一個CGPoint。因此,它應該是這個樣子

[UITapGesture recognizerWithHandler:^(UIGestureRecognizer *recognizer, UIGestureRecognizerState UIGestureRecognizerStateEnded, CGPoint point){ 
}]; 
+0

http://code.google.com/p/standard-iphone-app/source/browse/trunk/BKGlobals.h – bryanmac

+0

1 - 無效的typedef(^ BKGestureRecognizerBlock)(UIGestureRecognizer *發件人,UIGestureRecognizerState狀態,CGPoint位置); – bryanmac

0

UITapGestureRecognizer *singleTap = [UITapGestureRecognizer recognizerWithHandler:^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint point) { NSLog(@"Single tap."); } delay:0.18];

會工作。
不知道爲什麼,但示例here似乎是錯誤的。 BKGestureRecognizerBlock用3個參數聲明here。所以你的鏈接器是正確的抱怨。