Saleh
Saleh

Reputation: 380

TTPhotoViewController get current center image?

Is there a way to get a current image to an object of UIImage? I have tried casting TTPhoto to UIImage, but it doesn't work.

Upvotes: 3

Views: 227

Answers (2)

user470763
user470763

Reputation:

I did this differently. My Photo source is generated using JSON data so I couldn't use the method above as the photo source is different every time. Instead I used the URLForVersion method on TTPhoto to download the image into a UIImage.

NSURL *imageURL = [NSURL URLWithString:[self.centerPhoto URLForVersion:TTPhotoVersionLarge]];
NSData *imageData = [NSData dataWithContentsOfURL:imageURL];
UIImage *image = [UIImage imageWithData:imageData];

Upvotes: 2

Saleh
Saleh

Reputation: 380

I figured it out. We can use TTPhotoViewController's instance variable centerImageIndex. This will give us the index of the current image.

Upvotes: 1

Related Questions