zoukankan      html  css  js  c++  java
  • Touch

    前面写了几次提到UITouch,也提到了UITouch的三个代理方法

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

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

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

    这里还有几个代理方法

     

    - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;//触摸取消事件

     

    - (void)remoteControlReceivedWithEvent:(UIEvent *)event;//注册接受触摸事件的Control

    下面写了一个简单的DEMO,触摸时,移动图片

     

    - (void)loadView {

    [super loadView];

    // Release any retained subviews of the main view.

    // e.g. self.myOutlet = nil;

    UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(20.050.045.045.0)];

    image.image = [UIImage imageNamed:@"1.png"];

    image.tag = 100;

    [self.view addSubview:image];

     

    }

     

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

    {

    UITouch *touch = [touches anyObject];

    UIImageView *view1 = (UIImageView*)[self.view  viewWithTag:100];

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

    CGRect  frame = view1.frame;

    frame.origin = point;

    view1.frame = frame;

    }

    追寻最真
  • 相关阅读:
    Bean
    DI
    require import export
    JSON转js
    vue路由相关
    JS引号区别
    Go语言系列之标准库strconv
    Go语言系列之标准库flag
    Go语言系列之并发编程
    Go语言系列之自定义实现日志库
  • 原文地址:https://www.cnblogs.com/zhao-jie-li/p/5128477.html
Copyright © 2011-2022 走看看