首页 > 其他 > 详细

记录最大坐标

时间:2015-05-10 17:13:38      阅读:143      评论:0      收藏:0      [点我收藏+]
- (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);
        }

    }

 

记录最大坐标

原文:http://www.cnblogs.com/keyan1102/p/4492385.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!