UILongPressGestureRecognizer
fa già quello che vuoi per te. Dai un'occhiata alla proprietà UIGestureRecognizerState
. Da documentation:
I gesti a pressione prolungata sono continui. Il gesto inizia (UIGestureRecognizerStateBegan) quando il numero di dita consentite (numberOfTouchesRequired) è stato premuto per il periodo specificato (minimumPressDuration) ei tocchi non si spostano oltre l'intervallo consentito di movimento (consentito). Il gesto transizioni di riconoscimento allo stato Modifica ogni volta che un dito si sposta, e termina (UIGestureRecognizerStateEnded) quando viene sollevata una delle dita .
Quindi, in sostanza, dopo il vostro selettore UILongPressGestureRecognizer
è chiamato ascoltate UIGestureRecognizerStateBegan, UIGestureRecognizerStateChanged, UIGestureRecognizerStateEnded. Continua a cambiare la cornice delle visualizzazioni durante lo UIGestureRecognizerStateChanged
.
- (void)moveRight:(UILongPressGestureRecognizer *)gesture
{
if(gesture.state == UIGestureRecognizerStateBegan)
{
//if needed do some initial setup or init of views here
}
else if(gesture.state == UIGestureRecognizerStateChanged)
{
//move your views here.
[yourView setFrame:];
}
else if(gesture.state == UIGestureRecognizerStateEnded)
{
//else do cleanup
}
}
fonte
2012-02-14 06:00:23
sto usando \t CGPoint translatedPoint = [(UILongPressGestureRecognizer *) mittente translationInView: self.view] ; ma a lungo premere quello che devo usare? – PJR
try '[yourView setFrame: CGRectMake (xCoord, yCoord, height, width)]' –
ma da questo come posso ottenere tradottoPoint – PJR