我正在尝试实现NIPhotoScrollView,但我的代码无法正常工作,即数据源方法和委托方法未被调用

时间:2012-05-03 12:13:32

标签: ios nimbus

我一直在尝试实施NIPhotoAlbumScrollView http://jverkoey.github.com/nimbus/interface_n_i_photo_album_scroll_view.html。我在app bundle中使用照片。但是这段代码不起作用。这是完整代码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];
}

修改

不工作意味着 - 它不加载图像,甚至不显示加载图像

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

Just shows black screen

- (NSInteger)numberOfPagesInPagingScrollView:(NIPagingScrollView *)pagingScrollView或其他任何方法都没有被调用。

1 个答案:

答案 0 :(得分:0)

我忘了在loadView方法的开头添加[super loadView]。

// 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];
}