iOS 8: Autorotation Is Not Working Without Storyboard

iOS 8: Autorotation is not working without storyboard

Marked answer is to downgrade to XCode 6.0.1 - I do not recommend it.

1) If you do not use storyboards (Answer for this topic !!)

Go to -> Project Name -> Targets -> Project Name -> Deployment Info -> Main Interface -> Make it Empty


2) In case you use storyboards (not the main answer)

your AppDelegate should look like ...

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
{
return true
}

iOS 8.1 auto rotation

I had same issue many days and got answer from ChrisJP's link.

appdelegate.m file, comment the following code in application didFinishLaunchingWithOptions.

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

Here is the text from the link (in case it expires or people don't want to log in to the developer forums):

"I've managed to fix this!

I assume you guys are all using storyboards too? If so, you've probably got some old leftover code in your app delegate from when you weren't using storyboards, turns out this was no longer needed when storyboards are used, but until 8.1 has had no effect.

  1. Make sure your navigation controller (or whatever you're using) is set as "Initial View Controller" in your storyboard

  2. In your appdelegate.m file, remove any references to UIWindow and rootViewController that appear in application didFinishLaunchingWithOptions. For me, I still had the following two lines, which after removing, fixed my issues:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];

and also I was setting self.window.rootViewController. This also does not need to be set unless you're overriding it for some reason.

That's what fixed it for me, hopefully it does for you guys too."

Auto Rotation iOS 8 Navigation Controller

Just subclass UINavigationController and override appropriate methods:

.h File:

@interface CustomUINavigationController : UINavigationController
@property BOOL canRotate;
@end

.m File:

@implementation CustomUINavigationController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}

- (BOOL)shouldAutorotate
{
return self.canRotate;
}
@end

locking orientation does not work on ipad ios 8 swift xcode 6.2

You don't need extra code, I'm working on Xcode 7.0.1, I noticed that when I lock screen orientation to only portrait, it locks only in iPhones, to lock it in iPads also, you need to select iPad from Devices (instead of Universal) and check portrait and uncheck the others and then return Devices to Universal again, as I found that Universal only reflect in iPhones, it maybe some kind of bug in Xcode.

IOS 6 screen rotation without using storyboard

The solution is that:
Since my app is trying to support from 4.3+, I have to use the navigation controller to do every view switch.

by ios6 seems delegates to the navigation controller, I have to define my own navigation controller, and setup conditions and functions to change its rotation behaviour.

When I load a view, I then do([self.navigationCOntroller setEnableLandscape:(BOOL)false]). in that way you have full controller of your navigation controller.

NOTE: I did try override the navigation controller methods, but seems just get ignored. (This only happens to ios 6.0 as well), haven't test 6.1 yet, so not sure if it's get fixed(which please let me know if it does)



Related Topics



Leave a reply



Submit