TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2016 |
SPMSupports SPM | ✗ |
Maintained by Dan Jiang.
Browse multiple photos. Swipe left or right to see next or previous. Pinch to zoom in or out. Single tap should dismiss view controller.
iOS 8+
import DTPhotosViewController
class ViewController: UIViewController {
private let remoteImages = [NSURL(string: "/images/apple-keynote-20120912.jpg")!,
NSURL(string: "/images/apple-keynote-20140909.jpg")!,
NSURL(string: "/images/apple-keynote-20150909.jpg")!]
private let placeholderImage = UIImage(named: "placeholder_large")
@IBAction func manyRemotePhotos(sender: AnyObject) {
let photoURLs = remoteImages
let photosViewController = DTPhotosViewController(photoURLs: photoURLs, placeholderImage: placeholderImage, currentPage: 1)
photosViewController.handler = self
presentViewController(photosViewController, animated: true, completion: nil)
}
}
// MARK - DTPhotosViewControllerPhotosURLHandler
extension ViewController: DTPhotosViewControllerPhotosURLHandler {
func photosViewController(photosViewController: DTPhotosViewController, photoURL: NSURL, viewController: UIViewController) {
let networking = Networking(baseURL: "http://blog.danthought.com")
networking.downloadImage(photoURL.absoluteString) { image, error in
if let image = image {
dispatch_async(dispatch_get_main_queue(), {
photosViewController.setPhotoImage(image, forViewController: viewController)
})
} else {
print(error)
}
}
}
}
class ViewController: UIViewController {
private let localImages = [UIImage(named: "apple-keynote-20130910")!,
UIImage(named: "apple-keynote-20140602")!,
UIImage(named: "apple-keynote-20150309")!]
private let placeholderImage = UIImage(named: "placeholder_large")
@IBAction func manyLocalPhotos(sender: AnyObject) {
let photoImages = localImages
let photosViewController = DTPhotosViewController(photoImages: photoImages, placeholderImage: placeholderImage, currentPage: 1)
presentViewController(photosViewController, animated: true, completion: nil)
}
}