-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint pt = [touch locationInView:self.view];
if (!CGRectContainsPoint([self.view frame], pt)) {
NSLog(@"点pt不在self.view上");
}else{
NSLog(@"点pt在self.View上");
}
}
本文介绍了一个简单的iOS应用中如何处理触控事件。通过一段代码示例,展示了如何使用`touchesBegan`方法来判断触控点是否位于视图内,并据此进行不同的处理。

710

被折叠的 条评论
为什么被折叠?



