Giter Site home page Giter Site logo

Comments (4)

tapz avatar tapz commented on July 27, 2024

This is how I show the photo browsers:

class MyViewController: UITableViewController, PhotoBrowserDelegate {
    private var photos = [MWPhoto]()

    ...

    func showImageBrowser(images: [MyImage]) {
        photos.removeAll(keepCapacity: true)

        for image in images {
            if let url = NSURL(string: image.url) {
                photos.append(MWPhoto(url: url, caption: image.desc))
            }
        }

        let browser = PhotoBrowser(delegate: self)

        browser.navBarTintColor = Colors.myWhite
        browser.navBarBarTintColor = Colors.myBlue
        browser.navBarTranslucent = false
        browser.toolbarTintColor = Colors.myWhite
        browser.toolbarBackgroundColor = Colors.myBlueTranslucent
        browser.toolbarBarTintColor = Colors.myBlueTranslucent

        browser.displayActionButton = true
        browser.displayNavArrows = false
        browser.displaySelectionButtons = false
        browser.zoomPhotosToFill = true
        browser.alwaysShowControls = false
        browser.autoPlayOnAppear = false
        browser.startOnGrid = photos.count > 1
        browser.enableGrid = photos.count > 1
        browser.hideControlsOnStartup = 1 == photos.count

        let browserNavi = UINavigationController(rootViewController: browser)
        browserNavi.modalTransitionStyle = .CrossDissolve

        if 1 == photos.count {
            browserNavi.modalPresentationStyle = .FullScreen
        }

        navigationController?.presentViewController(browserNavi, animated: true, completion: nil)
    }

    func numberOfPhotosInPhotoBrowser(photoBrowser: PhotoBrowser) -> Int {
        return photos.count
    }

    func photoAtIndex(index: Int, photoBrowser: PhotoBrowser) -> Photo {
        return photos[index]
    }

    func thumbPhotoAtIndex(index: Int, photoBrowser: PhotoBrowser) -> Photo {
        return photos[index]
    }

    func titleForPhotoAtIndex(index: Int, photoBrowser: PhotoBrowser) -> String {
        return photos[index].caption
    }

    func photoBrowserDidFinishModalPresentation(photoBrowser: PhotoBrowser) {
        photoBrowser.dismissViewControllerAnimated(true, completion: nil)
    }

    func actionButtonPressedForPhotoAtIndex(index: Int, photoBrowser: PhotoBrowser) {

    }
}

from mwphotobrowserswift.

 avatar commented on July 27, 2024

could you give whole class? with tableview sections?
and what is [MyImage]? array with url's?

from mwphotobrowserswift.

tapz avatar tapz commented on July 27, 2024

I can't give the whole class as it's proprietary code. The table view code is in no way related to the photo browser. You could as well launch the photo browser from a button click. You just need to implement PhotoBrowserDelegate functions to any class, which can provide the image urls or the images.

MyImage is just a class, which has an url to the image. The photo browser uses MapleBacon image cache to load the image from the url and set it to a UIImageView.

from mwphotobrowserswift.

 avatar commented on July 27, 2024

if i could understand obj-c library example i didn't ask you for swift example. i dont know obj-c and just cant imagine how to implement this code to my project.
can you add example project?

from mwphotobrowserswift.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.