Hi there,
I appreciate the one callback function didFinishPicking, but when placed into the view life cycle, it doesn't activate when the save button is pressed(at the end of choosing, cropping, filtering, etc). Instead, it saves the photo to album and that's it. I needed to make an instagram based preview page to add a caption and what not in order to migrate.
Is there any way to do this without an edit to the pod? I had to edit the didSelect function's switch cases. I added a few lines of code, now the function presents the data I need on a new page which is going to allow me to add a post to my database. Also consider using a delegate/protocol for view controller communication.
If you can fix this, I think people may have a use case for this type of thing.
try
picker.pushviewcontroller(...)
@ewjc The single didFinishPicking is something we came up with internally after a long discussion.
There are drawbacks and advantages to both approaches (delegate vs callbacks) and we agreed this was more "swifty", although less common among libraries.
Your use case is perfectly valid.
If you want to dismiss the picker and present another sheet modally than you can use this :
func showPicker() {
var config = ...
let picker = YPImagePicker(configuration: config)
picker.didFinishPicking { [unowned picker] items, cancelled in
if cancelled {
picker.dismiss(animated: true, completion: nil)
return
}
let postVC = PostStatusVC()
if let photo = items.singlePhoto {
postVC.preloadedImage = photo.image
} else if let video = items.singleVideo, let videoData = try? Data(contentsOf: video.url) {
postVC.preloadVideo(with: videoData, thumbnail: video.thumbnail)
}
picker.dismiss(animated: true) {
present(postVC, animated: false, completion: nil)
}
}
present(picker, animated: false, completion: nil)
}
as @10000TB pointed out the picker is itself a UINavigationController so you can push your own views inside it natively.
Essentially replace
picker.dismiss(animated: true) {
present(postVC, animated: false, completion: nil)
}
in the above code by:
let myVC = MYViewController()
picker.pushViewController(myVC, animated: true)
Hope this helps :)
PS: Excuse the delayed response, we won the soccer World Cup so I was away for a while 馃嚝馃嚪 馃嵒 :)
Most helpful comment
@ewjc The single
didFinishPickingis something we came up with internally after a long discussion.There are drawbacks and advantages to both approaches (delegate vs callbacks) and we agreed this was more "swifty", although less common among libraries.
Your use case is perfectly valid.
If you want to dismiss the picker and present another sheet modally than you can use this :
as @10000TB pointed out the picker is itself a UINavigationController so you can push your own views inside it natively.
Essentially replace
in the above code by:
Hope this helps :)
PS: Excuse the delayed response, we won the soccer World Cup so I was away for a while 馃嚝馃嚪 馃嵒 :)