0

I am trying to create an action when I turn the screen of my device.

In the Apple documentation I have read that you have to use this method:

 override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
        println("I rotate.")
        self.tabBar.frame = CGRectMake(0, 80, self.view.bounds.size.width, self.view.bounds.size.height);
    }

But when I turn the screen in the log does not print "I rotate."

EDIT:

These are the settings of the project: enter image description here

Abubakr Dar
  • 4,078
  • 4
  • 22
  • 28
Stephany
  • 994
  • 1
  • 7
  • 18
  • the related documentation says that method is deprecated in iOS8, but you may need to take a look on how the orientation support works in iOS7+, because that method is not part of the 'new' procedure of supporting multiple orientations since. – holex Feb 06 '15 at 16:48

3 Answers3

1

The willRotateToInterfaceOrientation function is deprecated in iOS 8 as you can see in the Apple documentation here. See the discussion here on StackOverflow.

Community
  • 1
  • 1
codingminion
  • 401
  • 4
  • 7
0

From the documentation, you also are supposed to call super:

Your implementation of this method must call super at some point during its execution.

That shouldn't cause the issue you are seeing though. Double check that your target allows rotation. Go to your project, select the target, and under general make sure you have other orientations checked. If you have only one orientation checked then you can rotate the device, but it won't change orientation.

Jeremy Pope
  • 3,342
  • 1
  • 16
  • 17
0

Where is this method? It will only be called if in a subclass of UIViewController.

EDIT: It seems that willRotateToInterfaceOrientation is not called in a UITabBarController subclass (which seems to be what you're using) in iOS 8, but it is called in iOS 7. Even though the method is deprecated, it is still called in a direct subclass of UIViewController in iOS 8. But, for iOS 8 and above, it is preferable to use the new viewWillTransitionToSize:withTransitionCoordinator:.

Jose
  • 106
  • 4