UIScrollView setting contentoffset in viewwillappear not working
I was wondering if it is possible to set the contentoffset for a uiscrollview in viewwillappear mode.
-(void) viewWillAppear:(BOOL)animated{
[self.scrollView setContentOffset:CGPointMake(320, 0) animated:YES];
NSLog(@"CALLED");
}
I can see that the viewwillappear is working, but unfortunately it doesn't set the offset.
thank
+3
source to share
2 answers
you must call [super viewWillAppear:animated];
before trying to set the offset.
However, you may be trying to set the offset too early in the view lifecycle.
it might be useful to override -(void)viewDidLayoutSubviews;
and set the offset there.
as your view frames should be set appropriately by this time. (don't forget to call as well super
)
+13
source to share