记录最大坐标

- (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);
        }

    }

 

posted @ 2015-05-10 16:15  小天才努努  阅读(197)  评论(0编辑  收藏  举报