0

How do I allow one subview of my view controller to autorotate on an orientation change, but keep the others static. I'm trying to get an effect similar to the native camera app where the capture and switch cameras buttons (along with all the others) stay in their locations and just rotate accordingly. The SnapChat app also does this where the UI layer that pops up after you take a photo autorotates but the other views do not.

I seemed to be able to get close following the answers here: Disable autorotate on a single subview in iOS8, however, while this prevents them from rotating, it jumbles up their positions.

tallen11
  • 1,387
  • 2
  • 17
  • 33
  • Try this https://stackoverflow.com/a/41811798/10150796 – Nikunj Kumbhani Mar 28 '19 at 04:42
  • Thank you, however I'm looking to prevent the autorotation of UIViews (subviews of my view controller), not UIViewControllers, or some other way of accomplishing the same effect visually. – tallen11 Mar 28 '19 at 04:45

1 Answers1

0

I think you have to use (i) autolayout to set constraints on view by fixing its position or width height. for setting orientation for portrait and landscape you have to use size classes

(ii) Another trick is you can use UIViewController to fix orientation using its mask orientation delegate. then add it add child of other UIViewControllerenter image description here

Ajjjjjjjj
  • 669
  • 4
  • 12