Callbacks Cuando se desplaza un NSScrollView?
Estoy haciendo una aplicación para Mac que necesita saber cuándo el usuario está desplazándose por NSScrollView
, sin embargo, no puedo encontrar ningún método como UIScrollView
, que tiene los siguientes métodos delegados:
– scrollViewDidScroll:
– scrollViewWillBeginDragging:
– scrollViewDidEndDragging:willDecelerate:
– scrollViewShouldScrollToTop:
– scrollViewDidScrollToTop:
– scrollViewWillBeginDecelerating:
– scrollViewDidEndDecelerating:
¿Puedo tener los métodos delegados similares para el Kit de aplicaciones? Gracias de antemano.
Kai.
4 answers
Puede monitorear los cambios de una vista de desplazamiento monitoreando los límites de su vista de contenido. Primero establezca la vista de contenido para publicar sus cambios con
[contentView setPostsBoundsChangedNotifications:YES];
Luego regístrese como observador de esas notificaciones con
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boundsDidChange:) name:NSViewBoundsDidChangeNotification object:contentView];
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2011-03-02 15:34:29
Tuvo el mismo problema recientemente... Para emular un poco las devoluciones de llamada de desaceleración, es posible anular
-(void) scrollWheel:(NSEvent *)theEvent
De la clase NSScrollView, pero luego marque El evento.momentumPhase en lugar del evento.fase para fases de eventos.
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-12-12 08:04:44
Actualización para swift 4:
scrollView.contentView.postsBoundsChangedNotifications
También la llamada es: Centro de notificaciones.predeterminado.addObserver (self, selector: #selector (boundsChange), nombre: NSView.boundsDidChangeNotification, object: self)
Editar: la colección en mac no hereda de la colección. actualizado correctamente
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-07 09:19:03
Añadiendo a @Sean Rich respuesta.
El contentView
es el NSClipView
entre el NSScrollView
y NSCollectionView
.
Para que esto funcione, tanto el ClipView
necesita ser establecido en postsBoundsChangedNotifications
y debe ser pasado en el objeto de notificación.
self.clipView.postsBoundsChangedNotifications = true
NotificationCenter.default.addObserver(self,
selector: #selector(collectionViewDidScroll(notification:)),
name: NSView.boundsDidChangeNotification,
object: self.clipView)
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-06 03:45:20