2012-05-03 20 views
1

我一直在努力實現NIPhotoAlbumScrollView http://jverkoey.github.com/nimbus/interface_n_i_photo_album_scroll_view.html。我正在應用程序包中使用照片。但是這個代碼不起作用。下面是完整的代碼鏈接http://pastebin.com/ysvPL6ee我想實現NIPhotoScrollView但我的代碼不工作,即數據源方法和委託方法不被稱爲

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或任何其他方法沒有被調用。

+0

您將不得不指定「不工作」的含義。就目前來看,這個問題是無法回答的。 –

+0

@BradLarson我更新了我的問題。我似乎無法理解數據源方法和委託方法未被調用的原因。 –

回答

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