mwaterfall / MWPhotoBrowser

A simple iOS photo and video browser with grid view, captions and selections.
MIT License
8.75k stars 2.71k forks source link

func photoBrowser(_ photoBrowser: MWPhotoBrowser!, photoAt index: UInt) -> MWPhotoProtocol! returns Nil #640

Open MuhammadNayabButt opened 6 years ago

MuhammadNayabButt commented 6 years ago

I have created simple browser with these 2 images let image1 = MWPhoto.init(image: UIImage.init(named: "home1")) let image2 = MWPhoto.init(image: UIImage.init(named: "home2"))

I created an array and have same images and the total size of array is 8. When I scroll through images at times I got blank Screen but coming back again the image can be displayed.

The images are not being downloaded from url they are simply stored in application. The index is within range. More importantly going back and forth the image can be seen easily. ` var photos : [MWPhoto]? let image1 = MWPhoto.init(image: UIImage.init(named: "home1")) let image2 = MWPhoto.init(image: UIImage.init(named: "home2")) photos = [image1, image2,image1, image2,image1, image2,image1, image2] as? [MWPhoto]

let browser = MWPhotoBrowser.init(delegate: self) browser?.displayActionButton = false; // 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 = true; // 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 = false; // Whether to allow the viewing of all the photo thumbnails on a grid (defaults to YES) browser?.startOnGrid = true; // Whether to start on the grid of thumbnails instead of the first photo (defaults to NO) browser?.autoPlayOnAppear = false; // Auto-play first video browser?.setCurrentPhotoIndex(1)
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 photo = self.photos![Int(index)] as! MWPhoto return photo // return self.photos![Int(index)] } `

screen shot 2018-08-20 at 11 58 45 am