UI Page controller adjusting to just landscape mode XCODE - iphone

recently I found a project with a page view controller which I really liked and decided to use in my own project.
http://www.wannabegeek.com/?p=168
The problem is, The page controller starts out in portrait and has an auto rotate feature to landscape. For my purposes, I don't need any auto rotate feature, I just want to be able to swipe back and forth between views in landscape mode only.
I tried changing the code, but was unsuccessful in making it landscape only, If someone could help edit the code to NOT auto-rotate, start in landscape, and stay in landscape that would be great!
Thank you.

You have to perform 2 changes :
set Initial Orientation to Landscape ( either Home button left / right )
set - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation to return NO

Lemme add more detail to Shivan's answer:
Select Landscape Left and Landscape Right in target. Tap on the project to get to this page.
2.In the ViewController.m look for shouldAutorotateToInterfaceOrientation, make it return NO. See the following code.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return NO;
}

Related

Making a UIView landscape

I have created an iPhone app, which is a tab bar application and only in portrait orientation.
From one tab I am presenting a modal view which contain UIImage view.
Can I make landscape orientation only to that view while rotating iPhone to 90 degree?
yes , you can.
There are a few settings, code part which need to make it.
Depends also for which version, hopefully aren't targeting all supported by xcode, because it is horrible. Better choose only one, like the lastest iOS.

Rotation in iOS6

There are many questions and answers about the changed rotation in iOS6.
But I have really not solved one problem about that.
Using Xcode 4.5.2.
If I do not set anything in the info.plist or by the buttons “Supported Interface Orientations”, the app will rotate between portrait and landscape depending of the device rotation.
Now I mean the rotation caused by how holding the device, not a default orientation when opening a ViewController.
I know how to prevent landscape mode
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait);
}
but it does not have any effect.
Yes it has effect if I add a FlipsideController from the NavBar. In FlipsideView the code above prevents the rotation.
In the other ViewControllers it does not have any effect at all, whatever code I write.
Take a Sample given by Apple, UICatalog.
Can anybode give me a hint how to controll the rotation for the whole table and also for a separate ViewController using code and not by the Buttons or info.plist which only gives a result for everything together which is not very practical for all views.

UIWebview in a modal view is being shown in portrait in Landscape mode

I browsed through most of the questions and tried almost everything. But bad part is that the issue is still there.
I have a UIVIew which is always launched in landscape mode and I am presenting a second view (detailView) as a full screen modal view.
The detailview has a UIwebview on top of it.
When I present the detailView as a modal view, the webview is being shown in portrait mode.
I am returning "YES" in shouldAutoRotateToInterfaceOrientation and also have set autoresize , autoresizingMask and scalePageToFit properties.
When I rotate the device, and when the detailView is in front, the webview arranges to landscape properly.
The issue is only when I present the modalView for the first time.
Rotating the device is adjusting the layout properly.
As far as I am aware ModalViews on the iPhone do not support Landscape View. The case may be different for iPhone 5.
But it sounds like you are setting the ModalView not the WebView to landscape, I'd suggest a different approach to handling this.
For Example you could animate the DetailView in like a ModalView so it starts in the correct orientation
If you are running your app on iOS 6 you will need the following code in the modal view controller to support the landscape orientation:
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL) shouldAutorotate {
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationLandscapeLeft;
}
Also, make sure you are testing on the actual device as opposed to the simulator because auto-rotation behaves differently on the simulator.
That will do the trick:
CGAffineTransform transform = CGAffineTransformIdentity;
webView.transform = CGAffineTransformRotate(transform,-M_PI/2);
OK. First of all, the question I had posted was not clear. My question was that, when I load a webview, in portrait, it was loading the webview elements in landscape mode(CSS), and was getting loaded as portrait mode(CSS) in landscape orientation.
Turns out that I was not applying the correct CSS style.
The fix I did was:
In ViewDidLoad and willAnimateRotation method, I am posting a notification to my javascript to update the style based on orientation :)

iPhone Game Landscape Orientation Issue

I am trying to make a simple iPhone game and I need the game to be in landscape mode. I can get the initial view to be landscape, but if remove the initial view and replace it with a new view (going from Main Menu to Game Screen) the new view is now in portrait mode. Also, if I switchback to the first view (removing the game screen and then creating the new menu view) the view is still in portrait mode. I have the Info.plist file set up correctly to initialize with landscape right and I have the GameViewController.m file set up with the following code:
-(BOOL) shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
I have read many postings about people having troubles with setting up the landscape orientation, but they always seem to be about the initial load of the app (only displaying one view). I can't seem to find any solutions for this problem. Can someone help me?
You have stumbled on to
one of the most famous bugs on the platform!
Congratulations for spotting it! Here:
iPhone app in landscape mode, 2008 systems
be sure to read the paragraph that begins: "An important reminder of the ADDITIONAL well-known problem at hand here......." !!
It gives you the solution, which is used in all apps.
Make sure that all the view controllers that are visible on screen support the landscape orientation. I would recommend, in your shouldAutorotateToInterfaceOrientation, to return UIInterfaceOrientationIsIsLandscape(interfaceOrientation); instead of your code. This will ensure that both landscape orientation will work. Can you share a bit more how you are switching from the main menu to the game screen?

Photo Picker app has same issue!

This is related to my previous thread, but opened a new one here as it involves Apple's own sample code.
Open the sample code and modify the app so it will display in landscape and add a textfield to the view.
Run the app and open the image picker, select an image and you will be returned to the previous screen in landscape as you would expect.
Now tap the text field and see the keyboard scroll into view....in portrait mode?
This happens on the iPad not the iPhone, what gives????
link text
I have found the answer on this forum :-)
"The keyboard will show up in the orientation of the statusbar, which doesn't always change with rotations for some reason. So if you want to display that view only in landscape set [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; or whichever orientation you want to prefer in your viewWillAppear method."
Although why it does not do this on the iPhone ????