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

can't add photos to datasource #271

Open
AntonVoropaiev opened this issue Sep 3, 2018 · 3 comments
Open

can't add photos to datasource #271

AntonVoropaiev opened this issue Sep 3, 2018 · 3 comments

Comments

@AntonVoropaiev
Copy link

Please help me!
i don't understand how to create datasource model for my controller. It requires as parameter NYTPhoto which is NSObject subclass, instead of UIImage, how its work?
I cant create instance of NYTPhotos because it hasnt any initializers. Sorry for questions ) need your help

@ismailtosun
Copy link

+1

@imaczealot
Copy link

Create your own class that inherits from NYPhoto like this:

class MyPhoto: NSObject, NYTPhoto {

var image: UIImage?
var imageData: Data?
var placeholderImage: UIImage?
var attributedCaptionTitle: NSAttributedString?
var attributedCaptionSummary: NSAttributedString?
var attributedCaptionCredit: NSAttributedString?

init(image: UIImage? = nil, imageData: NSData? = nil) {
    super.init()
    
    self.image = image
    self.imageData = imageData as Data?
}

}

Then you instantiate it and provide the ImageData or Image and then add it to a data source provider.

let photo = MyPhoto()
photo.image = image
photo.imageData = data
let photoDataSource = NYTPhotoViewerSinglePhotoDataSource(photo: photo)
let photosViewController = NYTPhotosViewController(dataSource: photoDataSource)

@UtkuDalmaz
Copy link

UtkuDalmaz commented Dec 7, 2018

Create your own class that inherits from NYPhoto like this:

class MyPhoto: NSObject, NYTPhoto {

var image: UIImage?
var imageData: Data?
var placeholderImage: UIImage?
var attributedCaptionTitle: NSAttributedString?
var attributedCaptionSummary: NSAttributedString?
var attributedCaptionCredit: NSAttributedString?

init(image: UIImage? = nil, imageData: NSData? = nil) {
    super.init()
    
    self.image = image
    self.imageData = imageData as Data?
}

}

Then you instantiate it and provide the ImageData or Image and then add it to a data source provider.

let photo = MyPhoto()
photo.image = image
photo.imageData = data
let photoDataSource = NYTPhotoViewerSinglePhotoDataSource(photo: photo)
let photosViewController = NYTPhotosViewController(dataSource: photoDataSource)

I guess you are developing SendBird sample UI.
I am also working on that.
With 2.0 version I get a black and empty screen for shared images on chat.
What could be the reason?

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

4 participants