Reputation: 51
I'm trying to build something similar to the pull to refresh concept so popular in iPhone applications using NSScrollView in Lion, but there's no such property as contentOffset, and the frame doesn't seem to be affected when I scroll above the limit. Is there any sample code around on how to do this? twitter for Mac does it pretty well but i don't know how they managed to accomplish it!
Upvotes: 3
Views: 1348
Reputation: 2925
Register for scrolling notifications like so:
[[scrollView contentView] setPostsBoundsChangedNotifications: YES];
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(viewDidScroll:) name:NSViewBoundsDidChangeNotification object:nil];
Then use [[scrollView contentView]bounds].origin.y
to determine how far the view is scrolled and to respond accordingly.
- (void)viewDidScroll:(NSNotification *)notification {
if ([[scrollView contentView]bounds].origin.y < 0) {
//Refresh here
}
}
Upvotes: 1