2011-02-09 83 views

回答

0

只实现

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 

{ 

UITouch *touch = [[event allTouches] anyObject]; 

CGPoint touchLocation = [touch locationInView:self.view]; 

//your logic 

} 

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 

{ 

//your logic 

} 


- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event 

{ 

//your logic 

} 

在你的代码中..我认为你可以想出其余的想法。

+0

谢谢...但问题是如何实现它在应用程序委托class.I知道它可以在视图控制器中完成。但是,在所有视图控制器中编写代码将非常繁琐 – illuminatus 2011-02-10 03:42:00

+0

应用程序委托不是UIResponder子类。屏幕上没有代表的可视化表示,所以您的建议是没有意义的。只要检测窗口的触摸,但你必须自己处理所有的触摸。 – futureelite7 2011-02-10 06:42:03

1

应用程序委托不是响应者。我将继承UIWindow,并重写它的事件处理方法,因为窗口首次获取所有触摸事件。

-1

与futureelilte7所说的相反,您的应用程序委托(在创建项目时生成)实际上是UIResponder的子类,并响应选择器touchesBegan:withEvent:和其他类似选择器。

- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    [super touchesBegan:touches withEvent:event]; 

    // your code here 
} 

这应该保留默认触摸行为,并给你一个机会做自己的自定义功能。

相关问题