2010-12-06 143 views
0

我正在使用touchesBegan:iphone touchesbegan

我觸摸一個物體並將其拖放到其他位置,但我也想在其原始位置上覆制一個物體。也就是說,在觸摸和拖動之後,應該在其原始位置上有一個副本。

下面是我的代碼:

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event 
{ 
    UITouch *touch=[[event allTouches]anyObject]; 
    CGPoint location=[touch locationInView:touch.view]; 
    image1.center=location; 
} 

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event 
{  
    [self touchesBegan:touches withEvent:event]; 
} 
+0

你的問題到底是什麼?請重新說明它! – LordT 2010-12-06 11:34:59

+0

好吧,我將詳細解釋,我有一個imageview命名爲image1,我添加touchesbegan當我們觸摸image1,我們可以將它移動到屏幕上的任何地方,但我想要的是保留圖像的副本在它的原始位置和另一個副本,我們可以拖動屏幕上的任希望這次我明確表示。 – neha 2010-12-06 12:11:44

回答

0

而不是移動圖像1創建和圖像2(在touchesBegan)和移動它(在touchesMoved

你必須從對象的上海華獲得觸摸你想要移動我相信。

您沒有顯示image1是什麼,因此沒有人可以確定如何複製該圖像。