You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import UIKit
import MWPhotoBrowser
class PhotoViewController: UINavigationController, MWPhotoBrowserDelegate {
var photos = [MWPhoto]()
override func viewDidLoad() {
super.viewDidLoad()
retrievePics()
initiateBrowser()
}
func initiateBrowser() {
let browser = MWPhotoBrowser(delegate: self)
browser?.displayActionButton = true // Show action button to allow sharing, copying, etc (defaults to YES)
browser?.displayNavArrows = false // Whether to display left and right nav arrows on toolbar (defaults to NO)
browser?.displaySelectionButtons = false // Whether selection buttons are shown on each image (defaults to NO)
browser?.zoomPhotosToFill = true // Images that almost fill the screen will be initially zoomed to fill (defaults to YES)
browser?.alwaysShowControls = false // Allows to control whether the bars and controls are always visible or whether they fade away to show the photo full (defaults to NO)
browser?.enableGrid = true // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES)
browser?.startOnGrid = false // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO)
self.navigationController?.pushViewController(browser!, animated: true)
}
func numberOfPhotos(in photoBrowser: MWPhotoBrowser!) -> UInt {
return UInt(photos.count)
}
func photoBrowser(_ photoBrowser: MWPhotoBrowser!, photoAt index: UInt) -> MWPhotoProtocol! {
let realIndex : Int = Int(index)
if index < photos.count {
return photos[realIndex]
}
return nil
}
}
I'm omitting my retrievePics() function for privacy purposes but essentially it converts UIImages to MWPhoto objects and appends them to the photos array.
The text was updated successfully, but these errors were encountered:
Ok I printed the photos array and it looks like the browser is initiated before the pictures are appended to the photos array through retrievePics(). In my ViewDidLoad I am calling retrievePics() then initiateBrowser() but the browser finishes initiating before any of the pictures are appended. How can I make sure all the pictures are appended before the browser is initiated?
Here is the setup I have so far:
I'm omitting my retrievePics() function for privacy purposes but essentially it converts UIImages to MWPhoto objects and appends them to the photos array.
The text was updated successfully, but these errors were encountered: