I have a structure like this
LoginViewController-->Root
LoginViewController-->UINav---->HomeViewController
Now I have to lock this orientation to portrait only for iPhone and have to provide both orientations for iPad
For the Login Controller, I wrote this
-(BOOL)shouldAutorotate{
if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
{
return YES;
}
else
{
return NO;
}
}
This is working fine. I got only a portrait orientation in iPhone and both portrait as well as landscape orientation in iPad
But the same piece of code is written in HomeViewController is not working. Is it due to the Navigation Controller which is embedded with HomeViewConroller.
Well. I got a fix for that myself. Posting the solution on what to do as it might help others too. Just uncheck the Device Orientation checks (LandscapeLeft and LandscapeRight) in Target->General
And write the same piece of code in every controller
This worked for me. Now I only get a portrait mode in iPhone and a landscape as well as a portrait mode in iPad.