NYTPhotoViewer
NYTPhotoViewer copied to clipboard
I can not turn pages when using the new API
Hello, I can not turn pages when using this method:
NYTPhotoViewerArrayDataSource *dataSource = [[NYTPhotoViewerArrayDataSource alloc] initWithPhotos:photos];
NYTPhotosViewController *photosViewController = [[NYTPhotosViewController alloc] initWithDataSource:dataSource initialPhoto:photoM delegate:nil];
[self presentViewController:photosViewController animated:NO completion:nil];
How do i solve this problem? thanks
I asked for more info here: https://github.com/NYTimes/NYTPhotoViewer/issues/258#issuecomment-362786643
Facing the same issue. It seems like _dataSource in NYTPhotosViewController is being set to nil. And when this delegate method is called, it finds the self.dataSouce as nil.
NSUInteger photoIndex = [self.dataSource indexOfPhoto:viewController.photo];
if (photoIndex == NSNotFound) {
return nil;
}
return [self newPhotoViewControllerForPhoto:[self.dataSource photoAtIndex:(photoIndex + 1)]];
}
Please fix this issue. Thanks
Just in case you guys didn't figure it out, the data source is a weak reference. You need to be holding onto it the calling class so that the reference sticks around long enough.
@StainlessStlRat Thanks!, I used a strong reference, now it works. Guys, you should use strong reference of the Data Source.