I have a scrollview that is set up to scroll back and forth between 2 pages. Each page uses different data for labels, etc… on the same view controller.
I need to re-load the data on each page, without exiting the ‘sub’ view.
For example, I navigate to page 1 in the scroll view. My web svc sends me updated data via notification. I need to reload the data that is on page 2, while still sitting on page 1… or at least reload that data the instant I start scrolling to page 2.
I hope this makes sense. Thanks in advance!
(snippet from my scrollView.. but I would think I need to add something in my subview..?)
- (void)loadScrollViewWithPage:(int)page {
if (page < 0) return;
if (page >= kNumberOfPages) return;
if ([controllerName isEqualToString:@"ClassicViewController"]){
ClassicViewController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null]) {
controller = [[ClassicViewController alloc] initWithPageNumber:page];
controller.referringObject = self.referringObject;
controller.user = self.user;
controller.pushedFromScroll = kTrue;
controller.theirRoll = self.theirRoll;
NSLog(@"page replaced # = %d", page);
[viewControllers replaceObjectAtIndex:page withObject:controller];
[controller release];
}
if (nil == controller.view.superview) {
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scrollView addSubview:controller.view];
}
}
}
You have some options, but I think if your data is posting a notification that it’s been updated, you should have the view controller for each page be responsible for updating the elements of their view. So –
NSNotificationCenter‘saddObserver:selector:name:objetmethod.addObserver...to update the view based on the changes.Hope this helps!