【发布时间】:2011-08-05 08:46:37
【问题描述】:
我有一个应用程序,我必须在其中移动图像,当鼠标触摸它移动的图像时会出现问题,但如果它触摸主视图,整个视图也在移动。
我试过 view.userInteractionEnabled=NO;
但在一个移动之后,整个视图都被冻结了。
我希望我的视图是静态的(不移动)
求救!!!
这里是代码
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
UIImageView *imgPimples = [[UIImageView alloc]init];
imgPimples = (UIImageView*)[touch view];
CGPoint touchLocation = [touch locationInView:imgPimples];
imgPimples.center = touchLocation;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
}
【问题讨论】:
-
你能把你的
touchesEndedtouchesMoved和touchesBegan代码贴出来吗?? -
您真的不想在 touchesMoved 中进行分配,尤其是在您不释放它的情况下!
-
实际上我在每次点击按钮时都添加了相同的图像,这就是我需要分配(我认为)我是初学者,所以不要深入了解它。
-
然后在触摸开始时创建按钮,而不是每次触摸移动时。目前,如果触摸移动,您会一键创建大量图像。
标签: iphone objective-c uiview uiviewcontroller touchesmoved