Skip to content

Commit

Permalink
Merge pull request #18 from bcylin/feature/ios-11-navigation-issue
Browse files Browse the repository at this point in the history
Fix iOS 11 Navigation Issue
  • Loading branch information
bcylin authored Oct 9, 2017
2 parents b8736d6 + dab5ee2 commit af46ed0
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
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

0 comments on commit af46ed0

Please sign in to comment.