MWPhotoBrowserSwift icon indicating copy to clipboard operation
MWPhotoBrowserSwift copied to clipboard

how I can get the properties of currentPhotoIndex ??

Open JOMEN5 opened this issue 8 years ago • 16 comments

When I set the 'browser.startOnGrid = false' ,what I want to do is that custom decide which image should be show for first, so I need to get access the properties of currentPhotoIndex.

JOMEN5 avatar Aug 22 '16 11:08 JOMEN5

I'm sorry to bother you but I really look forward you reply! Thanks.

JOMEN5 avatar Aug 22 '16 11:08 JOMEN5

When I use the old pod of MWPhotoBrowser,I can easily make things work by using 'setCurrentPhotoIndex', when I use your pod,I don't know how to do.

JOMEN5 avatar Aug 22 '16 11:08 JOMEN5

@JOMEN5 hey func didDisplayPhotoAtIndex(index: Int, photoBrowser: PhotoBrowser) {

//index is thecurrentPhotoIndex..... } you can set your current photo index through this function... Hope this is helpfull :)

sreeji44 avatar Sep 02 '16 04:09 sreeji44

@sreeji44 Thanks for your reply! But I really want is set currentPhotoIndex,when I try your method and write the code "index = 3",then I get a error " Cannot assign to value: 'index' is a 'let' constant".For example,there are five photos in PhotoBrowser,I want to set the third photo to be show for first,no the first photo of default. What should I do.

JOMEN5 avatar Sep 07 '16 14:09 JOMEN5

@JOMEN5 for me i have done this defore. i have two pages one for showing photos gird view.(collectionview). when we select that cell we will get indexpath.row. you want to use seque for that to get indexpath.row to next page... i will show example for that

                    `  //collectionView.swift page
                       func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {
              dispatch_async(dispatch_get_main_queue(), {
                  self.performSegueWithIdentifier("PhotoDisplay", sender: self)
               })

               }

              ///seque
              override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
    //********* PHOTODISPLAYVIEWCONTROLLER******///
              if segue.identifier == "PhotoDisplay"  &&                   segue.destinationViewController.isKindOfClass(UINavigationController.classForCoder()) {
         let indexPaths  = collectionViewDisplay.indexPathsForSelectedItems()
        let indexPath   = indexPaths![0] as NSIndexPath
        let cell        = collectionViewDisplay.cellForItemAtIndexPath(indexPath)! as!           PhotosCollectionCell
               let Index   = indexPath.row
            let PhotoV  = segue.destinationViewController as! UINavigationController
           let PhotoVc = PhotoV.topViewController as! PhotoDisplayViewController
           PhotoVc.IndexPath   = Index

           }

                         //PhotoDisplayViewController.swift
                         var IndexPath : Int!

            func didDisplayPhotoAtIndex(index: Int, photoBrowser: PhotoBrowser) {
            indexPath = index

      }

          in viewDidload



    let browser = PhotoBrowser(delegate: self)

    // Set options
    browser.displayActionButton     = true // Show action button to allow sharing, copying, etc (defaults to YES)
    browser.displayNavArrows        = true // 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)
    browser.enableSwipeToDismiss    = false
    browser.hideControlsOnStartup   = false

    browser.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Done", style: .Done, target: self, action: #selector(PhotoDisplayViewController.done))
    browser.navigationItem.backBarButtonItem = nil
   browser.currentPhotoIndex = IndexPath // imp just tryy it...` 

hope it will help you

sreeji44 avatar Sep 08 '16 04:09 sreeji44

@sreeji44 Hey ,I just try this ,but when I write the code "browser.currentPhotoIndex = IndexPath",I get a error "Value of type 'PhotoBrowser' has no member 'currentPhotoIndex'"........

JOMEN5 avatar Sep 08 '16 05:09 JOMEN5

@JOMEN5 Can you show me the code if you dont have problem. Then i can check it. :)

sreeji44 avatar Sep 08 '16 05:09 sreeji44

@sreeji44 When you write the code "let browser = PhotoBrowser(delegate: self),browser.currentPhotoIndex = index",have you get the error just like me get "Value of type 'PhotoBrowser' has no member 'currentPhotoIndex"?

JOMEN5 avatar Sep 08 '16 05:09 JOMEN5

@sreeji44 I means 'browser.currentPhotoIndex = index ' is a error code in my project.

JOMEN5 avatar Sep 08 '16 05:09 JOMEN5

@JOMEN5 for me its works. i dont get any error message just like you. :)

sreeji44 avatar Sep 08 '16 05:09 sreeji44

@sreeji44 In my Podfile,I user 'pod 'MWPhotoBrowserSwift', :git => 'https://github.com/taps/MWPhotoBrowserSwift.git'' to install this pod,what about you?I don't know why I get this error

JOMEN5 avatar Sep 11 '16 06:09 JOMEN5

@sreeji44 If your project is open,can you give your source code to me for learn?

JOMEN5 avatar Sep 11 '16 06:09 JOMEN5

pod 'MWPhotoBrowserSwift', :git => 'https://github.com/tapz/MWPhotoBrowserSwift.git' this is i am using... I think you have spelling mistakes while adding @JOMEN5

sreeji44 avatar Sep 12 '16 04:09 sreeji44

@sreeji44 I use the statement just like yours.My Xcode version is 7.3

JOMEN5 avatar Sep 12 '16 04:09 JOMEN5

@JOMEN5 Did u fix this problem? I also encountered this problem

skyscrapy avatar Oct 18 '16 16:10 skyscrapy

@zzj19931010 NO,I haven’t.I have give up this swift pod but use object-c pod .

JOMEN5 avatar Oct 20 '16 00:10 JOMEN5