Skip to content
New issue

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

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

Already on GitHub? # to your account

Fix iPad crash #126

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion FDTake.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "FDTake"
s.version = "3.0.0"
s.version = "3.0.1"
s.summary = "Easily take a photo or video or choose from library"
s.description = <<-DESC
`FDTake` helps you quickly to have the user take or choose an existing photo or video.
Expand Down
15 changes: 11 additions & 4 deletions Sources/FDTake/FDTakeController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ open class FDTakeController: NSObject {
if self.allowsSelectFromLibrary {
if UIImagePickerController.isSourceTypeAvailable(.photoLibrary) {
titleToSource.append((buttonTitle: .chooseFromLibrary, source: .photoLibrary))
titleToSource.append((buttonTitle: .lastTakenMedia, source: .photoLibrary))
// titleToSource.append((buttonTitle: .lastTakenMedia, source: .photoLibrary))
} else if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum) {
titleToSource.append((buttonTitle: .chooseFromPhotoRoll, source: .savedPhotosAlbum))
}
Expand Down Expand Up @@ -236,12 +236,18 @@ open class FDTakeController: NSObject {
// set the media type: photo or video
self.imagePicker.allowsEditing = self.allowsEditing
var mediaTypes = [String]()
if self.allowsPhoto {
if self.allowsPhoto && title == .takePhoto {
// take photo choisen
mediaTypes.append(String(kUTTypeImage))
} else if self.allowsVideo && title == .takeVideo {
// take video choisen
mediaTypes.append(String(kUTTypeMovie))
} else if self.allowsTake {
// take from library
mediaTypes.append(String(kUTTypeImage))
}
if self.allowsVideo {
mediaTypes.append(String(kUTTypeMovie))
}

self.imagePicker.mediaTypes = mediaTypes

if title == .lastTakenMedia {
Expand All @@ -261,6 +267,7 @@ open class FDTakeController: NSObject {
// On iPad use pop-overs.
self.imagePicker.modalPresentationStyle = .popover
self.imagePicker.popoverPresentationController?.sourceRect = popOverPresentRect
self.imagePicker.popoverPresentationController?.sourceView = self.presentingView
topVC.present(self.imagePicker, animated: true, completion: nil)
}
}
Expand Down