1

我一直在尝试实现 NIPhotoAlbumScrollView http://jverkoey.github.com/nimbus/interface_n_i_photo_album_scroll_view.html。我在应用程序包中使用照片。但是这段代码不起作用。这是完整代码的链接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")];

只显示黑屏

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

4

1 回答 1

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];
}
于 2012-05-04T10:26:26.907 回答