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

Cant exit from gallery after showing a preview of selected Image? #27

Closed
jaisan123 opened this issue May 26, 2017 · 9 comments
Closed

Comments

@jaisan123
Copy link

First of all,thanks for this amazing plugin.
Actually i want to select only one image and on done button action ,show a preview of that image in a new viewController.
i used this code to show it within the did selectImages delegate method,
`func galleryController(_ controller: GalleryController, didSelectImages images: [UIImage])
{

    imageSelected = images
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let cont = storyboard.instantiateViewController(withIdentifier: "FilterAndEdit")
   
   // self.navigationController?.pushViewController(controller, animated: true)
   self.present(cont, animated: true, completion: nil)
    
   let appDelegate = UIApplication.shared.delegate as! AppDelegate
    //show
   appDelegate.window?.rootViewController = cont
  
}

it show another viewController with the selected image,And on back button action on that viewController,its moving back to Gallery also.. Then comes the problem,After coming back from previewVC,the close button of gallery is not working.it pops the gallery again and again. i using this code in galleryControllerDidCancel delegate method.func galleryControllerDidCancel(_ controller: GalleryController)
{

controller.dismiss(animated: false) {
    
    self.tabBarController?.selectedIndex = 0

    }
    
}

`
Im opening this gallery on tapping a tabbar under the screen.Also i getting a warning like

Attempt to present <XXXXX.FilterAndEdit: 0x7fbd8955ee40> on <XXXXX.uploadTab: 0x7fbd89511dc0> whose view is not in the window hierarchy!

Please help me to solve this.

@onmyway133
Copy link
Contributor

@jaisan123 Hi, appDelegate.window?.rootViewController = cont is not the recommended way to show a view controller

@jaisan123
Copy link
Author

jaisan123 commented May 26, 2017 via email

@onmyway133
Copy link
Contributor

@jaisan123 can you show me the updated code? Also you can take a look at https://github.com/hyperoslo/Gallery/blob/master/Example/GalleryDemo/GalleryDemo/Sources/ViewController.swift to check if you do anything wrong

@jaisan123
Copy link
Author

updated code is like this sir.
func galleryController(_ controller: GalleryController, didSelectImages images: [UIImage])
{

    imageSelected = images
    let storyboard = UIStoryboard(name: "Main", bundle: nil)
    let cont = storyboard.instantiateViewController(withIdentifier: "FilterAndEdit")
   self.present(cont, animated: true, completion: nil)
    

}

@onmyway133
Copy link
Contributor

@jaisan123 Hi, have you taken a look at the example I gave? Can you just dismiss gallery first before showing another view controller?

func galleryController(_ controller: GalleryController, didSelectImages images: [UIImage]) {
  controller.dismiss(animated: true, completion: nil)
}

@jaisan123
Copy link
Author

ya..i did that step also..but still the problem persists.
Actually my app have 5 tabs.on a tab action this gallery is showing.

@onmyway133
Copy link
Contributor

@jaisan123 Hi, without seeing the full picture, it's hard for me to tell. It would be great if you can minimise the use case, and send a sample project that can replicate this issue

@jaisan123
Copy link
Author

jaisan123 commented Aug 23, 2017

@onmyway133 ,thanks for the reply after months.I fixed it already.
I just written a observer for that action.
thanks man for the awesome Gallery.

@onmyway133
Copy link
Contributor

@jaisan123 Hi, glad that you found the solution

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

2 participants