Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setProgress not working in Swift, docs need updating #133

Open
ghost opened this issue Jan 23, 2017 · 2 comments
Open

setProgress not working in Swift, docs need updating #133

ghost opened this issue Jan 23, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 23, 2017

Hi guys,

First off, thanks for putting this really amazing looking library out there

Could someone please provide a solution as to how to implement this beautiful library in Swift

I can load the OverlayView but I can't figure out how to connect the progress

I am using Alamofire

In my post request

var progressFloat: Float = 0.0
...
                    upload.uploadProgress(closure: { //Get Progress
                        progress in

                        print(progress.fractionCompleted)

                       // cast value as float
                       progressFloat = Float(progress.fractionCompleted)
                        
                        // the initial overlay view gets loaded 
                        MRProgressOverlayView.showOverlayAdded(to: self.view, title: "Uploading", mode: MRProgressOverlayViewMode.determinateCircular, animated: true)
                        
                        // this is where I am stuck 
                        // setProgress is a child, but throws error:
//  'use of instance member 'setProgress' on type MRProgressOverlayView'; did you mean to use a value of type MRProgressOverlayView
                        MRProgressOverlayView.setProgress(progressFloat, true)

                      // MRProgressView.setProgress doesn't work either 

I am also getting the error 
/Pods/MRProgress/src/Components/MRProgressOverlayView.m:815
2017-01-23 16:23:32.207 MyProject[5844:139083] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Mode must support setProgress:animated:, but doesnot!'

                        if progress.fractionCompleted == 1 {
                            print("Completed")
 
                            // this is also throwing an error 
                            MRProgressOverlayView.dismiss(self)
                        }
                    })
@ghost ghost changed the title Please update the docs for Swift implementation setProgress not working in Swift, docs need updating Jan 23, 2017
@ghost
Copy link
Author

ghost commented Jan 23, 2017

@ghost
Copy link
Author

ghost commented Jan 24, 2017

You can add this to the docs for integration with Alamofire 4 and Swift 3

       let overlay = MRProgressOverlayView.showOverlayAdded(to: self.view, title: "Uploading", mode: .determinateCircular, animated: true)
                        
       upload.uploadProgress(closure: { //Get Progress
              progress in
                            
              print(progress.fractionCompleted)
                            
              self.progressFloat = Float(progress.fractionCompleted)
                            
              if progress.fractionCompleted < 1 {
                                
                         overlay?.setProgress(self.progressFloat, animated: true)
                                
              }
                            
              if progress.fractionCompleted == 1 {
                       print("Completed")
                           
                        overlay?.dismiss(true)                                
               }
     })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants