setAnimationDidStopSelector: diferentes usos y avanzados

En la mayoría de los casos, o porque estamos acostumbrados o porque hemos visto en los tutoriales y en algunos textos, se utiliza el setAnimationDidStopSelector de esta manera:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
nil context : NULL ] ; [BeginAnimations UIView: contexto nada: NULL];
1.5 ] ; [UIView setAnimationDuration: 1,5];
UIViewAnimationCurveEaseInOut ] ; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
self ] ; [SetAnimationDelegate UIView: auto];
@selector ( removeView ) ] ; [UIView setAnimationDidStopSelector: @ selector (removeView)];

; myView.alpha = 0;

; [CommitAnimations UIView];

/ /

void ) removeView { - (Void) {removeView
; [MyView removeFromSuperview];
}

come delegato e tramite la setAnimationDidStopSelector gli invia un messaggio removeView quando l'animazione è terminata. En el código anterior el setAnimationDelegate conjunto self como delegado ya través de setAnimationDidStopSelector envía un mensaje removeView cuando la animación ha terminado. El código es correcto, sin embargo, hace uso de una definición de mensaje ( removeView ) que podrían ser omitidos. Ahora, aquí es el mismo código, con el mismo efecto, sin el mensaje de removeView :

1
2
3
4
5
6
7
8
9
nil context : NULL ] ; [BeginAnimations UIView: contexto nada: NULL];
1.5 ] ; [UIView setAnimationDuration: 1,5];
UIViewAnimationCurveEaseInOut ] ; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
myView ] ; [SetAnimationDelegate UIView: myView];
@selector ( removeFromSuperview ) ] ; [UIView setAnimationDidStopSelector: @ selector (removeFromSuperview)];

; myView.alpha = 0;

; [CommitAnimations UIView];

! Lo interesante de este enfoque es que myView podría ser una subclase de UIView ! Por lo tanto, puede ser una clase personalizada con nuestros propios mensajes y, como se dijo, fácilmente se puede llamar desde setAnimationDidStopSelector . Además, el setAnimationDidStopSelector selectores de acuerdo con los parámetros:

1
2
3
4
5
6
7
8
9
nil context : NULL ] ; [BeginAnimations UIView: contexto nada: NULL];
1.5 ] ; [UIView setAnimationDuration: 1,5];
UIViewAnimationCurveEaseInOut ] ; [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
myView ] ; [SetAnimationDelegate UIView: myView];
@selector ( myMessage : param1 : ) ] ; [UIView setAnimationDidStopSelector: @ selector (myMessage: param1:)];

; myView.alpha = 0;

; [CommitAnimations UIView];

En este ejemplo se puede extender a todos los casos aquí, donde hemos establecido un delegado, Atro no es un puntero a una instancia de un objeto.

One Response to "setAnimationDidStopSelector: diferentes usos y avanzado"

  1. 27 de octubre 2010 Objective-C: manejar múltiples animaciones con un solo setAnimationDidStopSelector | Undolog.com :

    [...] Con setAnimationDidStopSelector en una clase UIView es extremadamente versátil, como se ve en setAnimationDidStopSelector: diferentes usos y avanzado. Permítanme ahora mostrar una técnica muy útil cuando tenemos varias animaciones y / o [...]

Deja un comentario

XHTML PERMISO TAG: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> código de inserción:
 <pre></pre> // blocco generico <code></code> // blocco generico [cc_actionscript][/cc_actionscript] // Actionscript [cc_actionscript3][/cc_actionscript3] // Actionscript 3 [cc_css][/cc_css] // CSS Style Sheet [cc_html][/cc_html] // HTML [cc_js][/cc_js] // Javascript [cc_objc][/cc_objc] // Objective-C [cc_php][/cc_objc] // PHP [cc_sql][/cc_sql] // SQL 


Dejar de SOPA