我有一個應用程序,我必須移動圖像,問題出現在鼠標碰到圖像時被移動,但如果它觸及主視圖,整個視圖也在移動。在TouchesMoved上禁用UIView
我試過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
{
}
你可以發佈你的'touchesEnded'' touchesMoved'和'touchesBegan'代碼嗎? – Hisenberg
你真的不想在touchesMoved中做一個alloc,特別是如果你不釋放它! – ader
實際上,我在每次點擊按鈕時添加了相同的圖像,這就是我需要分配(我認爲)一個初學者對此沒有深入瞭解。 –