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

Fix iOS 11 Navigation Issue #18

Merged
merged 3 commits into from
Oct 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ before_install:
install:
- bundle install --jobs=3 --retry=3 --deployment
- bundle exec pod install --project-directory=Example
before_script:
- if [ -n "$DANGER_GITHUB_API_TOKEN" ]; then bundle exec danger; else echo "Missing DANGER_GITHUB_API_TOKEN"; fi
script:
- make -B test
- make -B carthage
- make -B docs
- bundle exec danger
notifications:
email: false
slack:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Drop iOS 8 support [#13](https://github.com/carousell/pickle/pull/13)
* Rename `imagePickerController(_:didDeselectImageAsset:)` [#12](https://github.com/carousell/pickle/pull/12)
* Workaround the navigation issue in iOS 11 when the Photos permission is denied [#18](https://github.com/carousell/pickle/pull/18)

## v1.1.0

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions Pickle.xcworkspace
13 changes: 11 additions & 2 deletions Pickle/Classes/ImagePickerController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ open class ImagePickerController: UINavigationController {
open override var title: String? {
didSet {
albumButton.title = title
albumButton.isHidden = title?.isEmpty ?? true
}
}

Expand Down Expand Up @@ -239,8 +240,8 @@ extension ImagePickerController: UIImagePickerControllerDelegate, UINavigationCo
public func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
switch PHPhotoLibrary.authorizationStatus() {
case .denied, .restricted:
picker.dismiss(animated: false) {
self.cancel(nil)
picker.dismiss(animated: false) { [weak self] in
self?.cancel(nil)
}
default:
picker.dismiss(animated: true, completion: nil)
Expand Down Expand Up @@ -351,6 +352,14 @@ fileprivate extension ImagePickerController {
galleryViewController = PhotoGalleryViewController(album: cameraRoll.firstObject, configuration: configuration)

case .denied, .restricted:
// Workaround the issue in iOS 11 where UIImagePickerController doesn't show the permission denied message.
// It requires additional PHAuthorizationStatus check before presenting Pickle.ImagePickerController.
if #available(iOS 11.0, *) {
// Hide the album button and display an empty gallery with a cancel button to dismiss the image picker.
title = nil
galleryViewController = PhotoGalleryViewController()
return
}
let controller = systemPhotoLibraryController
showPermissionErrorIfNeeded = { [weak self] in
self?.present(controller, animated: false, completion: {
Expand Down