Comments (4)
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.
could you give whole class? with tableview sections?
and what is [MyImage]? array with url's?
from mwphotobrowserswift.
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.
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)
- how we create a custom uibarbutton for toolbars ?
- how I can get the properties of currentPhotoIndex ?? HOT 16
- About Selections
- Rotate problem HOT 2
- Convert to Swift 3 and add Header Section HOT 3
- Download button doesnt work HOT 3
- Can install cocoa pods with MWPhotoBrowserSwift - how you need time to construction? )) HOT 4
- How change Done Button title? HOT 2
- Method showNextPhotoAnimated
- Not able to install using cocoapods HOT 1
- when i add 2 delegate it showing that it doesnt conform to photobrowserdelegate ?.. HOT 1
- How can i use tab bar controller in the bottom instead of toolbar..
- How to view a specific image full-screen on load?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mwphotobrowserswift.