I have a iphone app where I want to present one of the views modally in landscape mode only and have set the code below its view controller. All works fine on the iphone (its intended platform), but when run on the iPad for demonstration, the left hand edge of the landscape view is truncated by approx 10 pixels. i.e. it looks like the display is too wide for the screen. No other views are affected and the same thing happens at 1x or 2x zoom.
Is this a bug or have I missed something?
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
InterfaceOrientation can return "unknown" value, in these cases you can encounter the case that the iPad thinks it is rotated and your code will return the wrong result
Related
I have an app, haven't modified it since 6 months ago, anyway I decided to open it up in the simulator. But the first viewcontroller which shows after the splash screen is scrunched up and is showing through the wrong orientation. It's showing in portrait when it should be showing in landscape.
This is the code for it:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
However,
When I tap to go to another view, then go back to the main viewcontroller, the problem fixes itself and the orientation is correct.
So it only happens on the initial launch after the splash screen is shown.
Please join the links together to view the screenshots as i cannot post images as i haven't got 10 reps yet.
This will make sure the app to open in landscape mode .
In the AppDelegate you may be using this
[self.window addSubView:viewControllerObj]
The problem was with the above line. Orientation will work properly with the above line in iOS 5 but in iOS 6, for orientation to work properly, change the above line with
[self.window setRootViewController:viewControllerObj]
Then the app rotates when orientation changes
Open your plist file ->addRow-> add "Initial interface orientation" and give value Landscape (left home button).
Hope this will help you.
I have an universal project, and want to keep landscape from very beginning of star-up for iPhone and portrait for Pad. How can I do it?
That's not possible. iPhone apps always have to start in Portrait orientation. Any game you see that has landscape-only display is still starting showing a portrait default image and the root view controller then can be landscape-only.
On iPad you can restrict the app orientation to Landscape and also have it start in Landscape.
The iPhone restriction is enforced by Apple and they won't approve an iPhone app that restricts itself to Landscape start.
If the device is already in landscape position it will start as landscape, but if you want your program to work always in landscape position and never flip to portrait, you have to set the orientation to landscape in each class you create:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscape || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown);
}
I am using the interface builder in Xcode 4. I have created a 480(w)x320(h) image to use in landscape mode for my app. WIthin IB I set the view's orientation to "landscape". I place my image on the view. I have set the "supported device orientation" to landscape letf/right. I have changed the info.plist to support landscape orientations.
Here's the weird part: When I run the app, the simulator does rotate/start in landscape, however, my image has somehow rotated 90 degrees as well so it appears cropped and and only takes up about 1/3 of the screen.
So to simplify the explanation, the image always appears in the opposite rotation of the view. I have tried removiong the .png file and re-adding and performing a "clean" with no luck. ANy advice?
you shoukd to modify your shouldAutorotateToInterfaceOrientation metho in all your viewControllers, that should be in landscape:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
return YES;
}
}
I changed the properties in info.plist to support orientation in landscape thereby the app opens in landscape mode as well. The problem which i face is like when the app loads in landscape mode the view is properly aligned. There is a view on the right side of the split view is not aligned properly. But when i load that in the portrait mode and then into landscape there are no issue. Can you tell me if there are additional properties or some work around for this issue.
as you are using splitview controller you should not worry about orientation.
just see in your view .nib file there is one authosizing feature set that properly u will remove this problem.
This link may help you if you dont know about autosizing.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
add this code...hope it will work...
I have two apps, both of which force the user to use the iPhone in landscape mode, in order to have a wider screen, instead of a taller one.
One of the things I have found is that my first view will look fine, but all other views come up with their subviews (UIButtons, UIPicker, UIViews) squeezed to one side or clipped (depending on whether the elements were set to move, resize or stay in the same position as the view size changed). All my views are designed in IB in the landscape orientation. My underlying UIWindow, and everything I can think of has been laid out in landscape orientation. Even my plist file has the UIInterfaceOrientationLandscapeRight flag set.
Now, if I load all my views at the same time as my rootview controller, then I have no problems. But if I have views loaded later, they get clipped or squeezed.
The only way to get around the problem was to add the following line in my code that flips in a new view:
[coming.view setFrame:CGRectMake(0, 0, 480, 300)];
Anyone know why I need to do this? Is it just that the iPhone assumes that loaded views are 300x480 unless a transform gets applied to them?
Thanks.
ps. This is what the view looks like if I don't call setFrame, as described above:
alt text http://files.me.com/mahboud/ljhvun
All viewcontrollers that get loaded after the first one will have their screen similarly squeezed down. For some reason the first viewcontroller doesn't have this issue.
I think you want to use landscape mode in each single view in your app. And you want the nib to be landscape mode too. You can resize the view to (0,0,480,300 for statusbar, 320 for non-statusbar) in nib. And design what you want. Finally, in view controller return no for autorotate. And finally transform the view and rotate.
I had a similar problem, asked the question on SO, and then figured it out and answered it myself. You may want to check it out.
A proper answer will depend on knowing how you are forcing landscape orientation. If you are doing this through UIViewController and company, it should be relatively simple; for other methods probably more complex.
In the simple case, you should be able to override shouldAutorotateToInterfaceOrientation: on your view controller, setup your views in Interface Builder, and set the UIInterfaceOrientation key to UIInterfaceOrientationLandscapeRight in your Info.plist and be set.
A simple way I fixed this was to have my root view controller subclass UINavigationController, and implement shouldAutorotateToInterfaceOrientation to handle landscape view ie,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight));
}
Every view controller that is pushed to the navigation controller seems to appear in landscape too.