How to fix a viewcontroller's rotation? - objective-c

My app uses landscape only. I fixed it via .plist's Supported interface orientations.
However, I need to use UIImagePickerController, and it only supports portrait mode. How can I rotate my app's rotation to portrait in a specific viewcontroller?
Any tips will be very helpful! Ty!

See the blog post iPhone programming: How to force your app to run in landscape mode.

ColinE, Do you mean that I should set as below?
All other viewControllers
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || UIInterfaceOrientationLandscapeLeft);
}
and set the portarit page
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

Related

Converting View from Landscape to Portrait?

I have already developed the app for Landscape mode,now the client is asking to build in both Landscape and Portrait mode.
How can i convert landscape View to portrait View?
Now i am using this code for Landscape View:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Please help me....
Advance Thanks :)
Simple, to support all orientations just return YES to shouldAutorotateToInterfaceOrientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
//Or to support all but portrait upside down
return interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown;
}
Learn how to use autoresizing masks. They are simple but pretty powerful in a majority of cases.
NSPostWhenIdle is right. You just have to return yes shouldAutorotateToInterfaceOrientation. That way you can have support for all orientations. Have a look at resizing properties through XIB. that will also make your work easy.

ipad rotation in iphone project

I've created a project that is targeted just for iPhone (for now) and I chose supported orientation only Portrait. On iPhone it works great, but when I launch my project on iPad my application is rotating! Actually I tried to make it a universal app and in iPad deployment info I chose supported orientation only Portrait, my app still rotated on iPad. How may I fix that?
To only support Portrait mode in your view, implement the following in each of your views:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Also, you need to make sure that have set the Supported Device Orientations for each device as well:
You can manually set the rotation values in the view controllers by implementing this function:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait;
}

universal xcode 3.2.6 Landscape mode by default

How can i create universal apps using xcode 3.2.6 in Landscape mode bydefault?I need seprate .xib files for each view,Is i have to use this code
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscape);
}
In your plist, you should change supported interface orientations to just two items :
Item 0 Landscape (right home button)
Item 1 Landscape (left home button)
And use in each view controller:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
I use this sample code and for making its View based i just hide its Navigation bar by using this code
self.navigationController.navigationBarHidden = YES;
in the RootViewController_Phone.h and in RootViewController_Pad
BenellingsonPost

iOS application's orientation remember?

I have several view controllers, which maintains only landscape mode and one view controller with all interface orientations(for example, slideshow). "Splash screen" can only in landscape mode. After "slideshow" is in portrait mode and I fully terminate application(from task bar too), application starts a "splash screen"(what should in landscape mode) unexpectly in portrait. But why it happens, if splash screen is actually not rotates in portrait if device rotated? And how to resolve this problem? Thanks.
In your SplashScreenViewController write:-
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}

Windows based iPad application orientation

I want to create iPad windows based application which support orientation by default windows application is not supporting orientation how to enable orientation support in windows based application in iPad.
Thank you
The window has no rotation functionality. It is allays in portrait mode. If you want something to rotate with the device, you should use UIViewController. It has to implement the method shouldAutorotateToInterfaceOrientation and return true for your orientations or remove it for all orientations.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
You should also change it in the project settings (ProjectName-Info.plist).