Originally posted at https://groups.google.com/forum/#!msg/nimbusios/nGePpdl12N4/Etnyp1cUOhMJ
Are there any examples available using NIToolbarPhotoViewController
with non-network images? I have the images in my application bundle
that I would like to present through this class. I have tried a few
tweaks of the NetworkPhotoAlbum example with my own subclass
(subclassing NIToolbarPhotoViewController directly, not
NetworkPhotoAlbumViewController). However, even when I hardcode the
following two methods in my subclass to return an image using +
imageNamed, I get blank screen.
- (UIImage *)photoAlbumScrollView: (NIPhotoAlbumScrollView *)photoAlbumScrollView
photoAtIndex: (NSInteger)photoIndex
photoSize: (NIPhotoScrollViewPhotoSize *)photoSize
isLoading: (BOOL *)isLoading
originalPhotoDimensions: (CGSize *)originalPhotoDimensions
- (UIImage *)photoScrubberView: (NIPhotoScrubberView *)photoScrubberView
thumbnailAtIndex: (NSInteger)thumbnailIndex
Based on my current understanding, it seems that any class should be
able to subclass NIToolbarPhotoViewController and implement these two
methods below as a very basic start. However, even with these two
datasource methods implemented as shown, I receive a blank screen.
Though, I still get the view showing the correct photo count (4 of 10,
for example) and can click through using the forward/back arrows, I
end up with no actuall images displaying. I was expecting the
default.png to show up 10 times.
- (NSInteger)numberOfPhotosInPhotoScrollView:(NIPhotoAlbumScrollView *)photoScrollView {
return 10;
}
- (UIImage *)photoAlbumScrollView: (NIPhotoAlbumScrollView *)photoAlbumScrollView
photoAtIndex: (NSInteger)photoIndex
photoSize: (NIPhotoScrollViewPhotoSize *)photoSize
isLoading: (BOOL *)isLoading
originalPhotoDimensions: (CGSize *)originalPhotoDimensions {
return [UIImage imageWithContentsOfFile:
NIPathForBundleResource(nil, @"NimbusPhotos.bundle/gfx/default.png")];
}
I was having the same problem. You need to assign a value to the photoSize (and originalPhotoDimensions should also be set, but it is not essential). I would have thought that the default behavior would have been to read the properties off of the image directly, but the default is (0,0).
This did the trick for me, it should for anyone else as well.