touchesMoviedwithevent函数怎么调用,需要包括头文件,还有在哪里加CODE,为什么每次都说没定义
    或者点图片移动具体的实现操作

解决方案 »

  1.   

    touchesMoviedwithevent这样的函数有四个,
    分别是
    -(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;
    这四个函数响应的事件从名字上就可以看出来,这四个函数定义在UIResponder中,而UIViewController类是继承自UIResponder类,所以,任何一个你工程中的ViewController类的子类都可以重载这四个函数,只需要在你的ViewController类的.m(即实现文件中)重载某个函数,你这个类即可处理相应的事件。不需要在.h(头文件)中声明,也不需要任何做什么设置。
    我马上发上来如何处理这些事件的说明。
      

  2.   

    在任何一个函数中写入下面的代码,你就可以得到事件发生所在点的位置
    // get current position of all touches
    NSArray *touchArray = [touches allObjects];

    // show positon of each touch
    for (UITouch *touch in touchArray)
    {
    CGPoint point = [touch locationInView: self.view];

    }
      

  3.   

    使用下面的代码可以分别当前的点击是双击还是单击,
    UITouch *touch = [touches anyObject];
    int tapCount = [touch tapCount];
      

  4.   

    -(void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event;
     比如说使用这个函数,他就说  touchesBegan 没定义 怎么回事
      

  5.   

    .h
      @interface draw: UIView{
       IBOutlet UITextField *textFied;
    }
    -(IBAction) vieMidText;
    @end
    .m
    -(void)viewMidText{     
        CGPoint *point[[CGPoint alloc] init];
        int mx=point.x;
        int my=point.y;
        textFied.text=@"%d,%d",ma,my ;}   我是把鼠标的坐标显示到屏幕中间,请问哪里错了,怎么改。
       上面说的,CGPoint不是OBJECTIEVE_C CLASS NAME
      

  6.   

    看一下CGPoint的定义,你会发现CGPoint是结构,不是一个类,所以不能用CGPoint *point=[[CGPoint alloc] init];方式。
    CGPoint point;就可以了,
    当然如果你一定要使用指针,那么请按照c语言的方式使用,(malloc之类的,你应该明白我在说什么的)