what method will called when we start to rotate device and after it finished
From Apple Docs:
Sent to the view controller just before the user interface begins rotating.
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
Sent to the view controller after the user interface rotates:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
See more here: UIViewController Class Reference -> Responding to View Rotation Events
ATTENTION: This is deprecated, see this post
For newcomers to this post, the methods suggested by Nekto have become deprecated in iOS 8. Apple suggests to use:
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator
You can use the "size" parameter as an easy way to get whether it is transitioning to portrait or landscape.
i.e.
if (size.width > size.height)
{
// Position elements for Landscape
}
else
{
// Position elements for Portrait
}
More info is availablein the Docs.