Domanda

Sto spostando le opinioni da questo codice, si sta muovendo bene ma a volte sono molto nervose, qualche idea su questo?

[[[(UITapGestureRecognizer*)sender view] layer] removeAllAnimations];

[self.view bringSubviewToFront:[(UIPanGestureRecognizer*)sender view]];
CGPoint translatedPoint = [(UIPanGestureRecognizer*)sender translationInView:self.view];

if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateBegan) {

    firstX = [[sender view] center].x;
    firstY = [[sender view] center].y;
}

translatedPoint = CGPointMake(firstX+translatedPoint.x, firstY+translatedPoint.y);

[[sender view] setCenter:translatedPoint];

if([(UIPanGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded) {

    CGFloat finalX = translatedPoint.x + (.35*[(UIPanGestureRecognizer*)sender velocityInView:self.view].x);
    CGFloat finalY = translatedPoint.y + (.35*[(UIPanGestureRecognizer*)sender velocityInView:self.view].y);


[UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:.35];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [[sender view] setCenter:CGPointMake(finalX, finalY)];
    [UIView commitAnimations];
È stato utile?

Soluzione

Non sembra che nulla nel tuo codice sopra rallenterebbe la panoramica. Qualsiasi risposta lenta sull'interfaccia utente è del 99% delle volte causata dalla riorganizzazione. Dai un'occhiata al tuo codice DrawRect (se l'hai implementato) per le viste che stai facendo una panoramica. Se questo viene chiamato ogni volta che la padella, questo potrebbe causare problemi. Puoi risolverlo impostando la proprietà Rasterize su SÌ nella tua vista.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top