zoukankan      html  css  js  c++  java
  • 记录最大坐标

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {
        
        NSArray *allTouches = [touches allObjects];
        
        if([allTouches count] >=2)
        {
            CGPoint p1 = [[allTouches objectAtIndex:0] locationInView:self];
            CGPoint p2 = [[allTouches objectAtIndex:1] locationInView:self];
            if(fabs(p2.y - p1.y) > 200)
            {
                [pointArr_1 release];
                pointArr_1 = [[NSMutableArray alloc] init];
    //            [pointArr_1 removeAllObjects];
                [self setNeedsDisplay];
            }
        }
        
        else
        {
            
            UITouch *touch = [touches anyObject];
            CGPoint pp = [touch     locationInView:self];
            [currentArr_1 addObject:NSStringFromCGPoint(pp)];
            [self setNeedsDisplay];
            
            
            [delegate touchMoved:[NSString stringWithFormat:@"%f",pp.x]
                            andY:[NSString stringWithFormat:@"%f",pp.y]];
            
    //        NSLog(@"pp.x = %f",pp.x);
            if (pp.x >= viewFrameBeginX && pp.x <= viewFrameEndX) 
            {
                if (pp.x > max_X) //获取最大位置
                {
                    max_X = pp.x;
                    [widthDic setValue:[NSNumber numberWithInt:max_X] forKey:@"maxX"];
                }
                if (pp.x < min_X) //获取最小位置
                {
                    min_X = pp.x;
                    [widthDic setValue:[NSNumber numberWithInt:min_X] forKey:@"minX"];
                }
    //            NSLog(@"widthDic = %@",widthDic);
            }
    
        }
  • 相关阅读:
    css常见布局问题
    jsonp原理及同源策略
    执行webpack-dev-server时,提示端口被占用。
    PHP中的<<<运算符
    PHP中的字符串类型
    数据库系统的结构
    HDU 2516 取石子游戏
    常用MySql命令列选
    mysql简单语句
    微信小程序-循环
  • 原文地址:https://www.cnblogs.com/keyan1102/p/4492385.html
Copyright © 2011-2022 走看看