如何处理单点touch

单点touch 基本上和各种编程里鼠标事件得处理差不多。

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

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

- (void) touchesEnd: (NSSet *) touches withEvent:(UIEvent *) event
搞定这三个类似mousedown,mousemove,mouseup得东西就可以了。
可以通过如下示例代码操作:
UITouch *touch= [[event allTouches] anyObject];
…你的代码
如何处理多点touch(Multitouch)
还是处理上面几个事件。在每一个事件里,可以通过如下示例代码操作
NSSet *allTouches = [event allTouches];
if ([allTouches count]==2){
    UITouch *touch1 = [[allTouches allObjects] objectAtIndex:0];
    UITouch *touch2 = [[allTouches allObjects] objectAtIndex:1];
    …你的代码
}
其中allTouches得count属性表示当前按下了几个触点,这里以最常用得两个触点为例,实际上理论上n个触点都可以,只要你手指头摆得下。
代码里有一行,NSSet *allTouches = [event allTouches]; 我们通过他获取到当前所有触点得信息,但是我们注意到touch事件里得第一个参数touches,他们有什么区别呢。当一个手指头不动得时候,只动另一个指头,这时,通过event allTouches可以获得所有得触点,而事件参数里得touches只能获得当前活动得那个触点信息。
(iu1u.com原创,欢迎转载,恳请注明来源)
怎么处理类似双击得操作
双击操作也是用的比较多得操作,可以通过touch对象得tapCount属性获取tap得次数,([touch tapCount]==2),就表示按了两下。
Over!
Posted in iphone开发 at 03月 5th, 2009. 1 Comment.

答案是官方sdk还不支持通过api设置iphone壁纸,toolchain当然可以,把你得图片文件写入/var/mobile/Library/LockBackground.jpg 即可。

Posted in iphone开发 at 03月 5th, 2009. No Comments.