The sample code linked here works great and allows a UIScrollView to display images with paging and preview of the images before and after the current image:
- http://blog.proculo.de/archives/180-Paging-enabled-UIScrollView-With-Previews.html
- https://github.com/alexrepty/Paging-Enabled-UIScrollView-With-Previews
I'm trying to encapsulate the example in a single control that can be reused. So I created a PagingScrollView:
@interface PagingScrollView : UIView {
IBOutlet UIScrollView * scrollView;
}
@property (nonatomic,retain) IBOutlet UIScrollView * scrollView;
@end
with dirt simple implementation
- (void) awakeFromNib
{
[super awakeFromNib];
NSLog(@"awake from nib");
}
In PagingScrollView.xib, I put a View containing a UIScrollView and a ARScrollViewEnhancer exactly as in the original ScrollViewPagingExampleViewController xib. Its File's Owner's class is set to PagingScrollView, and its scrollView outlet is set to the child UIScrollView.
In ScrollViewPagingExampleViewController, I simply declare:
IBOutlet PagingScrollView *pagingScrollView;
And in IB, I drag a View, set its class to PagingScrollView, and hook up its pagingScrollView outlet to the PagingScrollView.
In awakeFromNib, the scrollView property is nil. I would think that since the scrollView is hooked up in IB in the same nib, it would be available by this point.
Confusingly, in ScrollViewPagingExampleViewController.xib, there is an empty outlet named scrollView. This might indicate that there is a different instance of PagingScrollView than the one defined in PagingScrollView.xib.
As a result, I can't populate the UIScrollView with the actual child views. What am I doing wrong here?