-1

Scenario: I set the default device orientation to portrait. However, there are some Views that I want to allow for landscape mode.

Most of my views don't need to be in landscape. But there are some with orientation detection that allows a full-size linear graph to be displayed in landscape mode.

I want my application to behave as a Portrait-Centric for most of the time.

Question: How do I freeze the Portrait when I need to, but allow for Landscape when the situation warrants it?

Frederick C. Lee
  • 9,019
  • 17
  • 64
  • 105

1 Answers1

0

You can manually allow, and most importantly in your case, disallow device orientation through UIInterfaceOrientation. Full description was already answered here: https://stackoverflow.com/a/40859280/13296047

EJZ
  • 1,142
  • 1
  • 7
  • 26
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - [From Review](/review/low-quality-posts/28238151) – koen Feb 03 '21 at 21:10
  • 1
    The link references UIKit. I'm using SwiftUI. I'm going to try to work with it. Thanks. – Frederick C. Lee Feb 03 '21 at 21:34
  • 1
    @koen: This wouldn’t normally qualify as a link-only answer. The contributor suggests this can be accomplished using `UIInterfaceOrientation`. The link offers additional details. – Jeremy Caney Feb 04 '21 at 00:10
  • @FrederickC.Lee Did you figure it out? – EJZ Feb 08 '21 at 01:22
  • Not Yet. So far, I can handle orientation if I don't use the navigator. The Navigator View screws things up. So If I don't find a suitable solution, I'll mimic the navigator with a simpler 'flat' View. – Frederick C. Lee Feb 09 '21 at 02:04