- (void)swipeWithEvent:(NSEvent *)event not working on Lion?

让人想犯罪 __ 提交于 2019-12-08 07:10:38

问题


I'm writing a simple cocoa program that should use the swipe gesture. I've implemented in my NSView subclass the method swipeWithEvent: but when i try the program the method is never called. rotateWithEvent: method works instead. I'm using a Xcode 4.1 on Mac OS 10.7 Lion.

Is there a difference between rotateWithEvent: and swipeWithEvent: ?? Why the first is called when I'm under the view and do a rotate gesture and the second in the same condition is never called if i do the swipe gesture?

Update : I built also a simple project only to check the swipeWithEvent: and rotateWithEvent: methods but the behavior is the same.


回答1:


Take a look at this sample code I wrote https://github.com/oscardelben/CocoaNavigationGestures




回答2:


I think it would be helpful if you posted your code, reduced down to the bare essentials if possible.

One thing to look at is to make sure the method signature exactly matches the definition. In this case it should be:

- (void) swipeWithEvent: (NSEvent*) event
{
    NSLog( @"A swipe happened" );
}

Make sure your definition matches this. Since you have a rotateWithEvent: that is working correctly this is probably unlikely but sometimes a typo can creep in.

Another thing you can do is to make a sample project that does nothing but respond to a swipe by logging (or whatever). This can help identify if there is something else ii your code or view hierarchy that is getting in the way.



来源:https://stackoverflow.com/questions/7421687/voidswipewitheventnsevent-event-not-working-on-lion

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!