I am trying to automatically scroll to the far right side of a horizontal imagebrowser in the loadView method of the view controller that contains the browser. It doesn't work when I try to do this (just scrolling to x=1000 as a test):
- (void)loadView {
[super loadView];
// Set initial position
[[[self scrollView] documentView] scrollPoint:NSMakePoint(1000.0, 0.0)];
}
But at some point in the course of debugging I found that this works:
- (void)loadView {
[super loadView];
// Set initial position
[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(scrollToRight) userInfo:nil repeats:NO];
}
Where scrollToRight is just an instance method that does the same thing as above.
Does anybody know why this is the case? Is it because I'm doing it in the loadView method? Can scrollPoint: not be called from the main thread?
Update: I did some additional experimenting, like subscribing to an NSViewFrameDidChangeNotificaiton and scrolling based on that, but that doesn't work either. So far the only ways I've been able to get the scroll to happen is with NSTimer, or by calling the view controllers scrollToRight method from the parent window controller.