Advertisement
Guest User

Nimbus photoAlbumScrollView

a guest
May 3rd, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. AlbumViewController.h
  2.  
  3. @interface AlbumViewController : NIToolbarPhotoViewController <NIPhotoAlbumScrollViewDataSource>
  4. {
  5.     NSMutableArray* photoInformation;
  6. }
  7.  
  8. @end
  9.  
  10.  
  11. AlbumViewController.m
  12.  
  13.  
  14. //
  15. //  AlbumViewController.m
  16. //  NimbusPhoto
  17. //
  18. //  Created by Zakir Hyder on 5/1/12.
  19. //  Copyright (c) 2012 cybernetikz. All rights reserved.
  20. //
  21.  
  22. #import <Foundation/Foundation.h>
  23. #import <UIKit/UIKit.h>
  24.  
  25. #import "AlbumViewController.h"
  26.  
  27. @implementation AlbumViewController
  28.  
  29.  
  30. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  31. {
  32.     self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
  33.     if (self) {
  34.         // Custom initialization
  35.     }
  36.     return self;
  37. }
  38.  
  39. - (void)didReceiveMemoryWarning
  40. {
  41.     // Releases the view if it doesn't have a superview.
  42.     [super didReceiveMemoryWarning];
  43.    
  44.     // Release any cached data, images, etc that aren't in use.
  45. }
  46.  
  47. #pragma mark - View lifecycle
  48.  
  49.  
  50. // Implement loadView to create a view hierarchy programmatically, without using a nib.
  51. - (void)loadView
  52. {
  53.     photoInformation = [[NSMutableArray alloc] init];
  54.    
  55.    
  56.     for(int i=0; i<2; i++)
  57.     {
  58.         NSString* originalImageSource = @"Photo001.jpg";
  59.         NSString* thumbnailImageSource = @"img1.jpg";
  60.         NSDictionary* prunedPhotoInfo = [NSDictionary dictionaryWithObjectsAndKeys:
  61.                                             originalImageSource, @"originalSource",
  62.                                             thumbnailImageSource, @"thumbnailSource",
  63.                                             nil];
  64.         [photoInformation addObject:prunedPhotoInfo];
  65.     }
  66.    
  67.     self.photoAlbumView.dataSource = self;
  68.  
  69.     self.title = NSLocalizedString(@"Loading...", @"Navigation bar title - Loading a photo album");
  70.    
  71.     [self.navigationController setNavigationBarHidden:NO];
  72.    
  73.     [self.photoAlbumView reloadData];
  74.  
  75. }
  76.  
  77.  
  78. ///////////////////////////////////////////////////////////////////////////////////////////////////
  79. - (NSInteger)numberOfPagesInPagingScrollView:(NIPhotoAlbumScrollView *)photoScrollView {
  80.     return [photoInformation count];
  81. }
  82.  
  83.  
  84. ///////////////////////////////////////////////////////////////////////////////////////////////////
  85. - (UIImage *)photoAlbumScrollView: (NIPhotoAlbumScrollView *)photoAlbumScrollView
  86.                      photoAtIndex: (NSInteger)photoIndex
  87.                         photoSize: (NIPhotoScrollViewPhotoSize *)photoSize
  88.                         isLoading: (BOOL *)isLoading
  89.           originalPhotoDimensions: (CGSize *)originalPhotoDimensions
  90. {
  91.     NSDictionary* photo = [photoInformation objectAtIndex:photoIndex];
  92.     NSLog(@"%@",[photo objectForKey:@"originalSource"]);
  93.     UIImage* image = [UIImage imageNamed:[photo objectForKey:@"originalSource"]];
  94.    
  95.     return image;
  96. }
  97.  
  98.  
  99.  
  100. ///////////////////////////////////////////////////////////////////////////////////////////////////
  101. //- (id<NIPagingScrollViewPage>)pagingScrollView:(NIPagingScrollView *)pagingScrollView pageViewForIndex:(NSInteger)pageIndex
  102. - (id<NIPagingScrollViewPage>)pagingScrollView:(NIPagingScrollView *)pagingScrollView pageViewForIndex:(NSInteger)pageIndex {
  103.     return [self.photoAlbumView pagingScrollView:pagingScrollView pageViewForIndex:pageIndex];
  104. }
  105. @end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement