Search code examples
iosnimbus

I am trying to implement NIPhotoScrollView but My code is not working ie data source methods and delegate methods are not being called


I have been trying to implement NIPhotoAlbumScrollView http://jverkoey.github.com/nimbus/interface_n_i_photo_album_scroll_view.html. I am using photos in app bundle. But this code is not working. Here is link of full code http://pastebin.com/ysvPL6ee

AlbumViewController.h

@interface AlbumViewController : NIToolbarPhotoViewController    <NIPhotoAlbumScrollViewDataSource>
{
    NSMutableArray* photoInformation;
}
@end


#import "AlbumViewController.h"

@implementation AlbumViewController

#pragma mark - View lifecycle

// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
    photoInformation = [[NSMutableArray alloc] init];

    for(int i=0; i<2; i++)
    {
        NSString* originalImageSource = @"Photo001.jpg";
        NSString* thumbnailImageSource = @"img1.jpg";
        NSDictionary* prunedPhotoInfo = [NSDictionary dictionaryWithObjectsAndKeys:
                                            originalImageSource, @"originalSource",
                                            thumbnailImageSource, @"thumbnailSource",
                                            nil];
        [photoInformation addObject:prunedPhotoInfo];
    }

    self.photoAlbumView.dataSource = self;

    self.title = NSLocalizedString(@"Loading...", @"Navigation bar title - Loading a photo album");

    [self.navigationController setNavigationBarHidden:NO];

    [self.photoAlbumView reloadData];
}

Edit

Not working means - It does not load images and not even show loading image

self.photoAlbumView.loadingImage = [UIImage imageWithContentsOfFile:
                                    NIPathForBundleResource(nil, @"img1.jpg")];

Just shows black screen

The - (NSInteger)numberOfPagesInPagingScrollView:(NIPagingScrollView *)pagingScrollView or any other methods are not being called.


Solution

  • I forgot to add [super loadView] at the beginning of the loadView method.

    // Implement loadView to create a view hierarchy programmatically, without using a nib.
    - (void)loadView
    {
        [super loadView];
        photoInformation = [[NSMutableArray alloc] init];
    
        for(int i=0; i<2; i++)
        {
            NSString* originalImageSource = @"Photo001.jpg";
            NSString* thumbnailImageSource = @"img1.jpg";
            NSDictionary* prunedPhotoInfo = [NSDictionary dictionaryWithObjectsAndKeys:
                                                originalImageSource, @"originalSource",
                                                thumbnailImageSource, @"thumbnailSource",
                                                nil];
            [photoInformation addObject:prunedPhotoInfo];
        }
    
        self.photoAlbumView.dataSource = self;
    
        self.title = NSLocalizedString(@"Loading...", @"Navigation bar title - Loading a photo album");
    
        [self.navigationController setNavigationBarHidden:NO];
    
        [self.photoAlbumView reloadData];
    }