【问题标题】:I am trying to implement NIPhotoScrollView but My code is not working ie data source methods and delegate methods are not being called我正在尝试实现 NIPhotoScrollView 但我的代码不起作用,即未调用数据源方法和委托方法
【发布时间】:2012-05-03 12:13:32
【问题描述】:

我一直在尝试实现 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 或任何其他方法。

【问题讨论】:

  • 您必须指定“不工作”的含义。就目前而言,这个问题是无法回答的。
  • @BradLarson 我更新了我的问题。我似乎无法理解为什么不调用数据源方法和委托方法。

标签: ios nimbus


【解决方案1】:

我忘记在 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];
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-03-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-17
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多