开发者

how to bound uiimagegview moving in particular portion

I am working on an application in which I am adding the same image again and again on a button click on random positions and moving those images.

But on moving those images, images can move in whole view inspite of moving in UIView i want my image to move only in subview(UIImage view) on which i am adding it.

here is my code of TouchesMoved

- (voi开发者_C百科d)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {  

UITouch *touch = [[event allTouches] anyObject];

UIImageView *imgPimple;// = [[UIImageView alloc]init];
imgPimple = (UIImageView*)[touch view];

CGPoint touchLocation = [touch locationInView:imgPimple superview];

if ([touch.view isKindOfClass:[UIImageView class]])

{
    imgPimple.center = touchLocation;
}

}


What you should be doing is:

CGPoint touchLocation = [touch locationInView:[imgPimple superview]];

I think.

It seems to me that if you're deciding where to move it in its superview, and you get the touch location in the imgPimple view, it will behave incorrectly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜