Touch

来源:互联网 发布:薛之谦的淘宝店铺 编辑:程序博客网 时间:2024/05/16 16:22
///获取touch位置
 CGPoint touchPoint=[touch locationInView:self.view];
    NSString *str=[NSString stringWithFormat:@"%f",touchPoint.x];
    myLabel.text =str;


// handle new touches
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    myLabel.text =@"touch";

    [self processTouch:[touches anyObject]];
} // end method touchesBegan:withEvent:
-(void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
//当触摸序列被诸如电话呼入这样的系统事件所取消时,发送touchesCancelled:withEvent:消息。
{
    myLabel.text=@"cancelles";
}

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    myLabel.text=@"ended";
}
// exactly the same as touchesBegan:withEvent: minus double-tapping
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    myLabel.text=@"move";
   [self processTouch:[touches anyObject]];
} // end method touchesMoved:withEvent:
原创粉丝点击