enable interface orientation on a UIViewController [duplicate] - iphone

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
shouldAutorotateToInterfaceOrientation is not working in iOS 6
I am using xcode 4.5, I need to enable interface orientation only on one viewController containing a webview in it. How can i enable it.
- (BOOL)shouldAutorotateToInterfaceOrientation seems deprecated in iOS6

Instead you can use this UIViewController
-(BOOL) shouldAutorotate{
return YES; //supports all
}
-(NSUInteger) supportedInterfaceOrientations{
return UIInterfaceOrientationMaskAllButUpsideDown; //supports all but upside-down
}

This API does not works in iOS 6 anymore. There is no way that you can enable it. See the link shared by #Shivan Raptor

Related

iOS 7 Default image overlapped by status bar in multi-tasking view

My app is compiled against iOS 6 SDK (haven't gotten the time to upgrade to iOS 7 SDK). So I just noticed that the Default image is overlapped by the status bar. This seems to happen only in the "multi-tasking" view but not when resuming my app from background for some reason.
See this image:
I don't think many people will notice this at all.
However, as far as I know you could possibly disable the Statusbar when the app gets in backround.
To do this just use this method in the delegate:
- (void)applicationWillResignActive:(UIApplication *)application {
//code to disable statusbar
}
In the applicationDidBecomeActive method you could enable the statusbar again.
- (void)applicationDidBecomeActive:(UIApplication *)application {
//code to enable the statusbar
}
Furthermore you can take a look at this previous asked question: Status bar won't disappear
If you got any questions feel free to ask!
edgesForExtendedLayout does the trick for iOS 7. However, if you build the app across iOS 7 SDK and deploy it in iOS 6, the navigation bar appears translucent and the views go beneath it. So, to fix it for both iOS 7 as well as for iOS 6 do this:
self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
if ([self respondsToSelector:#selector(edgesForExtendedLayout)])
self.edgesForExtendedLayout = UIRectEdgeNone; // iOS 7

How to prevent autorotation in iPhone [duplicate]

This question already has answers here:
AutoRotate ONLY MpMoviePlayerControler iOS 6
(2 answers)
Closed 10 years ago.
In my iphone app I wish to rotate only one view when device rotated.How can I do this.
I have selected Supported interface orientation as Portrait,rotate right and rotate left
How can I rotate only one view.
Actually I want to rotate the MPMoviePlayer when it became full screen.
for your view controller set return value NO to shouldAutorotateToInterfaceOrientation
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return NO;
}
you can also remove it from Plist. UISupportedInterfaceOrientations
Your view controller needs to respond to
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
return YES to allow, and NO to disallow autorotation.
Better explanation is here:
AutoRotate ONLY MpMoviePlayerControler iOS 6
In your view controller, if don't want rotate add this
-(BOOL)shouldAutorotate
{
return NO;
}
In your view controller, if want rotate add this
-(BOOL)shouldAutorotate
{
return YES;
}

What are the changes in ios 6 as compare to previous versions of xcode?

I was build an app in ios 4.1 but now i am using ios 6 to build it but there are problems in pushviewcontroller and orientation methods. So can any one tell me what are the changes have brought in ios 6?
I think that best solution is to stick to official apple documentation. So according to that I use following methods and everything is working very well on iOS 5 and 6. In all of your ViewControllers override following methods.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
Methods for iOS 6, first method returns supported orientation mask (as their name indicate), you can change it into Landscape or what suites you best.
-(NSInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait; //UIInterfaceOrientationMaskPortrait or LandscapeLeft ...
}
second one thats tells your VC which is preferred interface orientation when VC is going to be displayed.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait; //tells your VC in which orientation it should be presented, if you set Porttrait it would be in Portrait or otherwise ...
}
This solution is working

IOS 6 view rotation issue [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Autorotate in iOS 6 has strange behaviour
I have issue with IOS 6, the display show up as portrait and not as landscape.
I am using both real and simulator device, if I build the game on 5.1 simulator the view is properly presented if I am using simulator version 6 or the real device with version 6 the view is get portrait view.
Here is my code.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight )
return YES;
Any idea how to solve such issue?
Thanks
ER
ShouldAutoRotation does not work anymore for iOS 6. Use supportedInterfaceOrientations instead.
You can get more information here: http://dhilipsiva.blogspot.com/2012/07/ios-6-ui-interface-orientation.html
Hope this helps.
The method shouldAutorotateToInterfaceOrientation has been deprecated for iOS 6. It has been replaced with the following:
- (BOOL)shouldAutoRotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
Also, there's a VERY important detail to make this work. In your AppDelegate, make sure you change the following:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[self.window setRootViewController:<your main view controller here>];
}
If you're using [self.window addSubview:self.mainViewController.view], it won't work.
If you want to support iOS 5 as well as iOS 6, leave shouldAutorotateToInterfaceOrientation in your code; just know that it won't be called on iOS6 devices.
The example #Simon gave should be able to coexist peacefully with your original code, with either operating system calling its applicable method. I was able to implement something similar in my app, but I used the project settings to set up autorotation for iOS 6 and just left my shouldAutorotateToInterfaceOrientation alone to make the app compatible with iOS 5 too.

iOS 6 Crashes on Device Rotation [duplicate]

This question already has answers here:
Closed 10 years ago.
THIS IS NOT A DUPLICATE QUESTION. A final working solution has NOT been provided yet. Please do not CLOSE this question until I have accepted an answer or found and provided my own solution for this. Thanks!
==================================================================
Using Xcode 4.5.1, I have a tab-bar app with 5 tabs in it. Each tab contains a UINavigationController. The entire App thus needs to be viewed in Portrait mode with the exception of one sole ViewController - a "modal" VC that opens in full screen and that's intended to be viewed in Landscape mode.
This worked perfectly well in iOS5 - I simply used the following code in that one particular ViewController:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
But now the App crashes, and gives this error:
Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation',
reason: 'preferredInterfaceOrientationForPresentation must return a supported interface orientation!'
Any suggestions?
Kindly check the What version xcode you used.
You used XCODE 4.5: shouldAutorotateToInterfaceOrientation delegate Depreciated.
You use following lines in your project.
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
-(BOOL)shouldAutorotate
{
return YES;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}
You need to use this to avoid iOS6 crash..
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_6_0
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAllButUpsideDown; //Getting error here? then update ur xcode to 4.5+
}
#endif
Remember one thing. In iOS 6
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
is deprecated.
You cannot use it in iOS 6. For supporting different interface orientation in viewControllers of a UINavigationController you need to subclass the UINavigationController or make a Category of it.
Code looks OK. it Should not have crashed for just that methods.
problem coud be in another part of code.
However ,here i would like to tell you.
Above shouldAutorotateToInterfaceOrientation methods orientation methods has deprecated in iOS 6.
if you want to know more how to fix orientation issue
you should take a look of this