ImageViewer icon indicating copy to clipboard operation
ImageViewer copied to clipboard

How to get the current picture data?

Open chenfengfeng opened this issue 7 years ago • 3 comments
trafficstars

For example: I have 9 pictures,want to get the third picture of the data

chenfengfeng avatar Feb 03 '18 07:02 chenfengfeng

I want to know too.I have to save current photo but cannot get it.

HuanjieGuo avatar Feb 14 '18 02:02 HuanjieGuo

GalleryViewController.currentIndex

springlo avatar Mar 13 '18 09:03 springlo

I'm looking for something similar... right now I came up with something like this:

galleryViewController.landedPageAtIndexCompletion = { index in
            let items = delegate.galleryItems
            let focusedItem = items[index]
            // try to get the image locally if possible, works for the initial image but not after that
            if let image = focusedItem.imageView?.image {
                shareView.image = image
                return
            }
            shareView.image = nil // will be set below
            switch focusedItem.galleryItem {
            case .image(let imageCompletionBlock):
                imageCompletionBlock { image in
                    shareView.image = image // my shareView is a custom view that allows saving the image
                }
            default: return
            }            
        }

This works fine, but the downside is that I'm fetching the image a second time over the network just so I can get access to it for saving purposes. There are probably other ways of getting access to the image w/o fetching it twice but this works for now. I may add some image caching into my code that handles the actual request to avoid fetching extra data.

camclendenin avatar Oct 12 '18 15:10 camclendenin