首页 新闻 会员 周边

新手问题:拖动图片后View上会留有图片划过的残影

0
悬赏园豆:20 [待解决问题]

一个图标拖动的小程序,拖动图片后界面上会留有图片划过的残影,不知道如何解决,请各位大侠指教

- (void)drawRect:(CGRect)rect {
       [imageBox drawInRect:CGRectMake(currentX, 329, imageBox.size.width, imageBox.size.height)];
}


-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    UITouch *t = [touches anyObject];
    CGPoint where = [t locationInView:self];
    
    CGRect rcBox = CGRectMake(currentX, 329, imageBox.size.width, imageBox.size.height);

    if(CGRectContainsPoint(rcBox, where))
    {
        touchBox = YES;
        currentX = where.x;
        [self setNeedsDisplay];
    }
}

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    if(touchBox)
    {
        UITouch *t = [touches anyObject];
        
        CGPoint where = [t locationInView:self];
        currentX = where.x;
        [self setNeedsDisplay];
    }
}

-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
    touchBox = NO;
    [self setNeedsDisplay];
}
迷迷糊糊学编程的主页 迷迷糊糊学编程 | 初学一级 | 园豆:184
提问于:2012-04-10 23:03
< >
分享
所有回答(2)
0

是在模拟器上吗?换到设备上试试。

zsounder | 园豆:2819 (老鸟四级) | 2012-04-11 09:06

都有的  , 不知道重绘图片的时候,背景是否还需要重绘才能清除残影?

支持(0) 反对(0) 迷迷糊糊学编程 | 园豆:184 (初学一级) | 2012-04-11 09:38
0

问题应该出在

imageBox drawInRect

里面,就如你所猜,应该时背景没有重绘的原因。

淡引 | 园豆:202 (菜鸟二级) | 2012-07-30 13:43
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册