Fake a landscape view in portrait only mode - objective-c

I have seen a similar question on Android but my question targets iOS. My app is portrait only and I have set up a landscape view which I would like to add to my current view, but there is no autorotation, the user manually rotates the device.
I have tried doing this but when I add it as a subview the view it comes out like this:
So as you can see it adds it as if the view is in landscape mode, how can I modify this? Thanks!

Make the view 480 wide and 320 tall in Interface Builder. Then use:
-(void)viewDidLoad {
myLandscapeView.transform =CGAffineTransformMake(0,1,-1,0,-80,80);
[self.view addSubview:myLandscapeView];
}

Related

lock a view to launch initially in landscape (ONLY landscape) objective-C

I want to initially launch one of the View controllers in JUST landscape mode, while the other views and the whole app can work in both portrait and landscape. How can I do it in iOS 7? Thank you.
So your whole app may supports all orientations but one view controller needs to be landscape only.
You can easily stop your landscape view controller to rotate from landscape to portrait but when the app is in portrait already then it is difficult to force the deivce to rotate as this contradicts the iPhone manufacturers priciple.
In fact, it is not really difficult when you know the trick. See my answer to this similar question.
Force controllers to Change their orientation in Either Portrait or Landscape

topLayoutGuide not updated after Rotation

I have a viewController (mainView) that supports every orientation on iPhone.
From this view, another viewController is presented with modal style, which only supports only Portrait orientation (and forces the orientation accordingly).
Usually, the topLayoutGuide is at y=20px and the layout of the toolbar right below is attached to that topLayoutGuide
Now i have the following sequence of events
display mainView in portrait orientation
open modal view in portrait orientation
turn to landscape orientation (modal view obviously stays in portrait orientation)
dismiss modal view and return to mainView
After this, the topLayoutGuide is suddenly at y=0px and therefore, the toolbar is positioned over the statusbar, and also keeps that value after rotation in the mainView.
Does anyone know how to update (or force) the topLayoutGuide back to 20px?
You can either adjust insets manually, or you can force the SDK to force to "refresh the orientation" of your controller.

UIViews are displayed distorted when I set statusBar to hidden

I have a bunch of UIViews that are displayed on a viewController. They are setup before I call presentModalViewController. The problem is that these views are displayed distorted, specifically they have an extra height of 20, which is the length of the status bar. The problem goes away if I have the statusBar shown or I have the UIViews setup after the viewController is shown, but I need the UIViews to be setup before the viewController is shown and I dont want the statusBar to be shown when my app
is running. How do I fix this?
You can try setting the Autoresize subviews property of the viewController's view to NO.

how to change mainwindow.xib's orientation to landscape? [duplicate]

I appreciate I'm probably missing something basic here, but...
My iPad app will only support landscape mode, and has a MainWindow.xib Window that I'd like to work on in landscape mode in XCode 4, however the pull-down menu to change this (Simulated Metrics -> Orientation) is always grayed out.
I notice that Views can be rotated just fine, it's only Windows that can't be rotated in XCode 4 using this setting.
Is there a workaround for this, or do I have to put a View on top of the MainWindow in order to rotate it?
I think it's because apps always starts up in portrait and then rotates to appropriate oriantations. From the UIViewController docs:
Note: At launch time, applications should always set up their
interface in a portrait orientation. After the
application:didFinishLaunchingWithOptions: method returns, the
application uses the view controller rotation mechanism described
above to rotate the views to the appropriate orientation prior to
showing the window.
So you'll need the UIViewController magic for the simulated metrics to make any sense. If you used the "Window-based application" template as a starting point for your project try the "View-based application" template instead.

Seems like it should be easy: Landscape Scrolling Text Field

I have a application that I am working on that is in landscape mode and does not rotate. However I can not get the text field to rotate. I have been putting in way to many hours so don't be to harsh if this is a easy answer...
Are you using Interface Builder to create the view? In that case, adding the UITextField to the UIView in landscape mode. In case you do not know how to use IB for creating views in landscape mode, open the UIView object in IB. There is a small arrow on the top-right corner of the view. Click on that arrow to rotate the view to landscape mode.
Edit your Info.plist file so that it includes the "Initial device orientation" key and specify UIDeviceOrientationLandscapeLeft (the Home button should be to the right if an app opens in landscape, according to Apple's UI guidelines). Some samples come with this property already in the plist, but most don't.