Comments (3)
Upon further examination, I think this is because if not authorized, a overlay is placed on the camera view. The current way doesn't care if the user allows for camera use because the overlay was already set. I think a better way is to only allow one to see the Camera view if they have authorized it. Otherwise, don't let them get there.
I think the following way is a good way to handle it.
The following code should suffice:
let authorizationState = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeVideo)
switch authorizationState {
case .Authorized:
self.presentViewController(pickerController, animated: true, completion: nil)
case .Denied:
let appName = NSBundle.mainBundle().infoDictionary?["CFBundleName"] as! String
let alertTitle = "\"\(appName)\" Would Like to Access the Camera"
let alert = UIAlertController(title: alertTitle, message: nil, preferredStyle: .Alert)
let dontAllowAction = UIAlertAction(title: "Don't Allow", style: .Default, handler: nil)
let goToSettingsAction = UIAlertAction(title: "Go To Settings", style: .Default, handler: { alert in
UIApplication.sharedApplication().openURL(NSURL(string:UIApplicationOpenSettingsURLString)!)
})
alert.addAction(goToSettingsAction)
alert.addAction(dontAllowAction)
self.presentViewController(alert, animated: true, completion: nil)
case .NotDetermined:
AVCaptureDevice.requestAccessForMediaType(AVMediaTypeVideo, completionHandler: { granted in
if granted {
dispatch_async(dispatch_get_main_queue()) {
self.presentViewController(pickerController, animated: true, completion: nil)
}
}
})
case .Restricted:
let alert = UIAlertController(title: "Feature is Restricted on this Device", message: nil, preferredStyle: .Alert)
let dismissAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil)
alert.addAction(dismissAction)
self.presentViewController(alert, animated: true, completion: nil)
}
Of course, you changed your solution to use DKCamera, so you'll need to refine it a bit to be able to inject this somewhere, but the logic holds.
from dkimagepickercontroller.
@dilizarov
Thanks for your solution! I'll check it! I think this will help me. Thanks again :)
from dkimagepickercontroller.
I will release the 3.0.0 with Photos framework. develop. I believe this will improve the issue.
from dkimagepickercontroller.
Related Issues (20)
- Top picker bar is transparent in iOS15
- Camera icon not showing when deploying in xcode13 HOT 3
- Localization not working
- Compilation error: "LLVM ERROR: out of memory" HOT 11
- Xcode 13.3 - Error (Xcode): Segmentation fault: 11 Encountered error while archiving for device. HOT 35
- Crash on DKCamera.captureImage function HOT 1
- How to get original files URLs?
- Xcode 14: Swift Compiler Error: Stored properties cannot be marked potentially unavailable with '@available' HOT 4
- ios error Signing for "DKImagePickerController-DKImagePickerController" requires a development team. HOT 14
- After changing to 4.3.4, Now i cant compile with BITCODE enabled HOT 4
- XCode 14 Build error: Stored properties cannot be marked potentially unavailable with '@available' HOT 16
- I want to export the video to .mp4
- xcode14中不兼容ios12系统
- No Actions when clicking in Camera Icon, it should open camera to capture
- How to perform Multiple Image selection but only single video selection
- Xcode 13 升级 14后,运行到真机没有问题但是打包会报错 HOT 4
- Error output from CocoaPods:
- Add tag 4.3.5 or higher to enable Swift Package Manager versioning support HOT 1
- Add tags to dependend packages in order to be able to fetch DKImagePickerController with a versioned rule
- Library not loaded: @rpath/DKImagePickerController.framework/DKImagePickerController HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dkimagepickercontroller.