App Crashing with UIImagePickerController in Landscape mode on iPhone X (iOS 12) only
Created Project in Xcode 10.1 with Device Orientation Landscape Left and Right Only.
Added the following Key in Plist
Privacy - Camera Usage Description: “Used for taking Picture”
import UIKit
class UploadViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate
{
//MARK:- ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func cameraButtonAction(_ sender: UIButton)
{
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.modalPresentationStyle = .overCurrentContext
imagePicker.delegate = self
self.present(imagePicker, animated: true, completion: nil)
}else{
let alert = UIAlertController(title: "Warning", message: "You don't have camera", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
Above code working fine in following devices
iPhone 8 (iOS 12)
iPhone 7 (iOS 11.4.1)
iPad mini (iOS 11)
But When I run this in iPhoneX with iOS 12.1, then Getting following error.
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [CAMViewfinderViewController shouldAutorotate] is returning YES'
*** First throw call stack:
libc++abi.dylib: terminating with uncaught exception of type NSException
I did the research on this issue but I'm not able to find the solution yet.
Here are few links that I found for the related issue but none of the answers working for iPhoneX.
Using UIImagePickerController in landscape orientation
UIImagePickerController InterfaceOrientation Crash
https://www.reddit.com/r/iOSProgramming/comments/3xpwot/discussion_lets_talk_about_landscape_cameras/
ios iphone swift iphone-x ios12
add a comment |
Created Project in Xcode 10.1 with Device Orientation Landscape Left and Right Only.
Added the following Key in Plist
Privacy - Camera Usage Description: “Used for taking Picture”
import UIKit
class UploadViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate
{
//MARK:- ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func cameraButtonAction(_ sender: UIButton)
{
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.modalPresentationStyle = .overCurrentContext
imagePicker.delegate = self
self.present(imagePicker, animated: true, completion: nil)
}else{
let alert = UIAlertController(title: "Warning", message: "You don't have camera", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
Above code working fine in following devices
iPhone 8 (iOS 12)
iPhone 7 (iOS 11.4.1)
iPad mini (iOS 11)
But When I run this in iPhoneX with iOS 12.1, then Getting following error.
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [CAMViewfinderViewController shouldAutorotate] is returning YES'
*** First throw call stack:
libc++abi.dylib: terminating with uncaught exception of type NSException
I did the research on this issue but I'm not able to find the solution yet.
Here are few links that I found for the related issue but none of the answers working for iPhoneX.
Using UIImagePickerController in landscape orientation
UIImagePickerController InterfaceOrientation Crash
https://www.reddit.com/r/iOSProgramming/comments/3xpwot/discussion_lets_talk_about_landscape_cameras/
ios iphone swift iphone-x ios12
see this for help : stackoverflow.com/questions/12540597/…
– Anbu.Karthik
Nov 19 '18 at 10:35
@Anbu.karthik: Thanks for your response but that solution didn't work .
– Vishal Khatri
Nov 26 '18 at 5:43
add a comment |
Created Project in Xcode 10.1 with Device Orientation Landscape Left and Right Only.
Added the following Key in Plist
Privacy - Camera Usage Description: “Used for taking Picture”
import UIKit
class UploadViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate
{
//MARK:- ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func cameraButtonAction(_ sender: UIButton)
{
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.modalPresentationStyle = .overCurrentContext
imagePicker.delegate = self
self.present(imagePicker, animated: true, completion: nil)
}else{
let alert = UIAlertController(title: "Warning", message: "You don't have camera", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
Above code working fine in following devices
iPhone 8 (iOS 12)
iPhone 7 (iOS 11.4.1)
iPad mini (iOS 11)
But When I run this in iPhoneX with iOS 12.1, then Getting following error.
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [CAMViewfinderViewController shouldAutorotate] is returning YES'
*** First throw call stack:
libc++abi.dylib: terminating with uncaught exception of type NSException
I did the research on this issue but I'm not able to find the solution yet.
Here are few links that I found for the related issue but none of the answers working for iPhoneX.
Using UIImagePickerController in landscape orientation
UIImagePickerController InterfaceOrientation Crash
https://www.reddit.com/r/iOSProgramming/comments/3xpwot/discussion_lets_talk_about_landscape_cameras/
ios iphone swift iphone-x ios12
Created Project in Xcode 10.1 with Device Orientation Landscape Left and Right Only.
Added the following Key in Plist
Privacy - Camera Usage Description: “Used for taking Picture”
import UIKit
class UploadViewController: UIViewController,UIImagePickerControllerDelegate,UINavigationControllerDelegate
{
//MARK:- ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func cameraButtonAction(_ sender: UIButton)
{
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.camera){
let imagePicker = UIImagePickerController()
imagePicker.sourceType = .camera
imagePicker.modalPresentationStyle = .overCurrentContext
imagePicker.delegate = self
self.present(imagePicker, animated: true, completion: nil)
}else{
let alert = UIAlertController(title: "Warning", message: "You don't have camera", preferredStyle: .alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
}
}
Above code working fine in following devices
iPhone 8 (iOS 12)
iPhone 7 (iOS 11.4.1)
iPad mini (iOS 11)
But When I run this in iPhoneX with iOS 12.1, then Getting following error.
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [CAMViewfinderViewController shouldAutorotate] is returning YES'
*** First throw call stack:
libc++abi.dylib: terminating with uncaught exception of type NSException
I did the research on this issue but I'm not able to find the solution yet.
Here are few links that I found for the related issue but none of the answers working for iPhoneX.
Using UIImagePickerController in landscape orientation
UIImagePickerController InterfaceOrientation Crash
https://www.reddit.com/r/iOSProgramming/comments/3xpwot/discussion_lets_talk_about_landscape_cameras/
ios iphone swift iphone-x ios12
ios iphone swift iphone-x ios12
asked Nov 19 '18 at 10:32
Vishal KhatriVishal Khatri
4412931
4412931
see this for help : stackoverflow.com/questions/12540597/…
– Anbu.Karthik
Nov 19 '18 at 10:35
@Anbu.karthik: Thanks for your response but that solution didn't work .
– Vishal Khatri
Nov 26 '18 at 5:43
add a comment |
see this for help : stackoverflow.com/questions/12540597/…
– Anbu.Karthik
Nov 19 '18 at 10:35
@Anbu.karthik: Thanks for your response but that solution didn't work .
– Vishal Khatri
Nov 26 '18 at 5:43
see this for help : stackoverflow.com/questions/12540597/…
– Anbu.Karthik
Nov 19 '18 at 10:35
see this for help : stackoverflow.com/questions/12540597/…
– Anbu.Karthik
Nov 19 '18 at 10:35
@Anbu.karthik: Thanks for your response but that solution didn't work .
– Vishal Khatri
Nov 26 '18 at 5:43
@Anbu.karthik: Thanks for your response but that solution didn't work .
– Vishal Khatri
Nov 26 '18 at 5:43
add a comment |
1 Answer
1
active
oldest
votes
I was also facing this issue since long and found a solution after doing so many RND's :
Step 1: Make Custom UIImage picker controller and use it. Code for same is below
class MyImagePickerViewController: UIImagePickerController {
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override public var shouldAutorotate: Bool {
return false
}
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape // Since your app is in only landscape mode
}
}
Step 2: Make a global flag isOpenGallery and just before opening gallery make it true and make it false just before dismiss MyImagepickercontroller and In your App Delegate implement following code:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return isOpenGallery ? UIInterfaceOrientationMask.portrait : UIInterfaceOrientationMask.landscape
}
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372686%2fapp-crashing-with-uiimagepickercontroller-in-landscape-mode-on-iphone-x-ios-12%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was also facing this issue since long and found a solution after doing so many RND's :
Step 1: Make Custom UIImage picker controller and use it. Code for same is below
class MyImagePickerViewController: UIImagePickerController {
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override public var shouldAutorotate: Bool {
return false
}
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape // Since your app is in only landscape mode
}
}
Step 2: Make a global flag isOpenGallery and just before opening gallery make it true and make it false just before dismiss MyImagepickercontroller and In your App Delegate implement following code:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return isOpenGallery ? UIInterfaceOrientationMask.portrait : UIInterfaceOrientationMask.landscape
}
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
add a comment |
I was also facing this issue since long and found a solution after doing so many RND's :
Step 1: Make Custom UIImage picker controller and use it. Code for same is below
class MyImagePickerViewController: UIImagePickerController {
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override public var shouldAutorotate: Bool {
return false
}
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape // Since your app is in only landscape mode
}
}
Step 2: Make a global flag isOpenGallery and just before opening gallery make it true and make it false just before dismiss MyImagepickercontroller and In your App Delegate implement following code:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return isOpenGallery ? UIInterfaceOrientationMask.portrait : UIInterfaceOrientationMask.landscape
}
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
add a comment |
I was also facing this issue since long and found a solution after doing so many RND's :
Step 1: Make Custom UIImage picker controller and use it. Code for same is below
class MyImagePickerViewController: UIImagePickerController {
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override public var shouldAutorotate: Bool {
return false
}
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape // Since your app is in only landscape mode
}
}
Step 2: Make a global flag isOpenGallery and just before opening gallery make it true and make it false just before dismiss MyImagepickercontroller and In your App Delegate implement following code:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return isOpenGallery ? UIInterfaceOrientationMask.portrait : UIInterfaceOrientationMask.landscape
}
I was also facing this issue since long and found a solution after doing so many RND's :
Step 1: Make Custom UIImage picker controller and use it. Code for same is below
class MyImagePickerViewController: UIImagePickerController {
override public func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override public var shouldAutorotate: Bool {
return false
}
override public var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return UIInterfaceOrientationMask.landscape // Since your app is in only landscape mode
}
}
Step 2: Make a global flag isOpenGallery and just before opening gallery make it true and make it false just before dismiss MyImagepickercontroller and In your App Delegate implement following code:
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return isOpenGallery ? UIInterfaceOrientationMask.portrait : UIInterfaceOrientationMask.landscape
}
edited Nov 19 '18 at 13:02
answered Nov 19 '18 at 12:43
Vitul GoyalVitul Goyal
717
717
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
add a comment |
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
:) very helpful answer bro thanks :)
– Anupam Gupta
Nov 30 '18 at 12:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372686%2fapp-crashing-with-uiimagepickercontroller-in-landscape-mode-on-iphone-x-ios-12%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
see this for help : stackoverflow.com/questions/12540597/…
– Anbu.Karthik
Nov 19 '18 at 10:35
@Anbu.karthik: Thanks for your response but that solution didn't work .
– Vishal Khatri
Nov 26 '18 at 5:43