younatics / MediaBrowser

🏞 A simple iOS photo and video browser with optional grid view, captions and selections written in Swift5.0
https://younatics.github.io/MediaBrowser/
MIT License
648 stars 117 forks source link

Error on MediaBrowser(media: [Media]) #59

Open YuStephen opened 6 years ago

YuStephen commented 6 years ago

Hello sir, when i use code like bottom to browser ,it doesn't show image and swipegesture doesn't work. so it's must have a delegate?

func showPhotoBrowser(photos: [Any], atIndex: Int, viewController: UIViewController) {

    var tempArray = [Media]()

    for i in photos{
        if i is UIImage{
            let photo = Media(image: i as! UIImage)
            tempArray .append(photo)
        }

        if i is String{
            let photo = Media(url: i as! URL)
            tempArray .append(photo)
        }
    }

    let browser = MediaBrowser(media: tempArray)
    browser.setCurrentIndex(at: atIndex)
    let nc = UINavigationController.init(rootViewController: browser)
    nc.modalTransitionStyle = .crossDissolve
    viewController.present(nc, animated: true, completion: nil)
}
SMFakhir commented 5 years ago

It seems so.