Changing from landscape right directly to landscape left - ios

When I change directly from landscape right to landscape left there is a bug.
I have a web view and image view. In each state I have declared specific width height and position. When I am in portrait mode I have specific coordinates for the views. I also have set them for the landscape modes. When I change quickly from landscape left to landscape right all the proportions gets messed up!
I need to have access to the state when my application is in landscape right mode and directly i rotate to landscape left. i need to access it to do modifications, and if i can't how can i then force my application to pass through the portrait mode before going to the other landscape mode, Ex:
Landscape right -> landscape left will take place as follows Landscape right -> Portrait -> landscape left.
Because if i rotate it directly from right to left i will have a bug in my software so i need to fix it.
Note that i am using a tab bar controller and i have successfully subclassed it and everything is ok.

The problem here was with my handling of the orientation change, i should have from the beginning used :
if(UIInterfaceOrientationIsPortrait(self.interfaceOrientation))
This handed me the option to control each state. Hope this helps a future person

Related

I am trying to get both landscape and portrait bottom safe area insets at once when the screen is loaded

I am trying to get bottom safe area insets for both portrait and landscape mode together when the screen is loaded. I know how to get the safe area inset for portrait mode when I am actually in portrait mode and landscape mode when I am actually in landscape mode separately.
if #available(iOS 11.0, *) {
let window =
UIApplication.shared.keyWindow
let bottomPadding =
window?.safeAreaInsets.bottom
}
This works good for that but I actually need this inset for both landscape and portrait mode irrespective of which mode I am actually in
Personally I think this is a very valid question. If I'm building a UI that has expensive layout calculations to be made and where the user can rotate from portrait to landscape, I would like to pre-calculate the UICollectionView section layouts for both landscape and portrait while the user is already sitting looking at a loading screen. At that point if it takes an extra half second they won't know or care. But when you rotate the device and the whole UI glitches to a halt that's a terrible experience.
Why are you not using Auto layout and compositional layouts (you may say), well maybe I am, and maybe they still simply don't manage my use cases. So maybe the above question would allow me to build a better user experience.

Tab Bar titles aren't staying in position when you change orientation

Heres the problem
Portrait Mode :
Landscape Mode :
So as you can see the offset doesnt scale properly, because i put 0,-17 when its potrait it shows normally but when you switch to landscape its the opposite like 0,17 instead. Im not sure how to fix..

One landscape view for whole app

How to setup just one landscape view for whole app? I want to show only one view (qrcode) when phone is rotated independently in wich view this happened. What is the easiest way to do it?
My app is in portrait and I want show users code when it rotated to landscape in whatever view this was done.
See this answer. Just untick Portrait and tick on whatever Landscape orientation you want.
http://stackoverflow.com/a/29791531/7198143
Edit:
You should use Autolayout in your Storyboard to set up the right constraints so even in Landscape mode, the label for the code shows up. See this tutorial for more info.
Autolayout tutorial

iPad - Different designs for landscape and portrait mode

I'm making an application for iPad in Xcode in template Master-detail application. I need to do a design for portrait mode and another for landscape mode. My first idea was make two UIViews and make a rule: if portrait, show View1, if landscape, show View2. But I have text fields in it and when the user will be typing something inside and then rotate the device, text will be deleted, because it will be another UIView... Can anybody help me, how to do it, please?
You can have one view and use springs and struts or use autolayout.
You can also add views and hide/show them based on the orientation change.
You can change the size and position of the view on orientation change.

landscape and portrait in split viewController

I created a split view controller application. I want to display my buttons and controls in landscape and portrait view differently(only the position).
When I change the orientation to landscape it shows the controls in portrait only. When I click on the cell in the tableview then it will show in correct position. What is the reason for that? Help me please.
I am a little confused about your question, but what I think you are trying to ask is how to change your view if the screen is in landscape or portrait orientation. Without seeing your code it is hard to tell you exactly how to do it, but the general idea (at least how I do it in my code) is that you want to split your code into two parts one that is in landscape orientation, and one that is in portrait orientation. You can tell the difference by seeing if the screen height is greater than the screen width.

Resources