Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can not turn pages when using the new API #259

Open
LayChan opened this issue Feb 3, 2018 · 4 comments
Open

I can not turn pages when using the new API #259

LayChan opened this issue Feb 3, 2018 · 4 comments

Comments

@LayChan
Copy link

LayChan commented Feb 3, 2018

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

@jamesstout
Copy link
Contributor

I asked for more info here: #258 (comment)

@ehsan-ff
Copy link

ehsan-ff commented Feb 11, 2018

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

@StainlessStlRat
Copy link

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.

@algenepulido
Copy link

@StainlessStlRat Thanks!, I used a strong reference, now it works. Guys, you should use strong reference of the Data Source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants