Please read before telling to view other threads on this matter of which I probably have already read.
I have a app that is using a tabbarcontroller with navigationcontrollers pushed onto the tabbar.
I have one particular view of which I want to give the user the option of either portrait or landscape. This is the only view I want to have that option, all other views must remain in portrait. The view in question is the detail view of navigation controller of which the user is drilling down via table views.
Based on posts here I was able to force the view to landscape via a transformation if I put the code to transform in the viewDidLoad method. The problem is that I don't want to force it but give the user the option of either portrait or landscape. When I take the code that is working fine in viewDidLoad and place it elsewhere it does not work. For instance I made a customized version of shouldAutorotateoreintatation to run the code when the device change oreintation and it does not work quite right. The view does transform and rotate. The navigation bar is rotated and displayed fine but the view it manages via a VC is rotated 90 degrees but is cut half and not quite centered correctly. Even changing the bounds and center of that view doesn't seem to fix it all up.
Here is the code I am using, please note I have tried doing the transform on the tabbar, navigation controller and just the view. The tab bar version worked fine in viewDidLoad.
Has anyone else had any success getting this to work outside of viewDidLoad,initWithFrame, or viewWillAppear??
PHP Code:
UIScreen *screen = [UIScreen mainScreen];
int y = screen.bounds.size.height;
int x = screen.bounds.size.width;
myApp *appDelegate = [[UIApplication sharedApplication] delegate];
UIViewController *myVC = appDelegate.tabBarController;
UIView *myView = myVC.view;
myView.bounds = CGRectMake(0.0, 0.0, y, x);
myView.center = CGPointMake(y / 2.00, x / 2.00);
CGAffineTransform landscapeTransform = CGAffineTransformMakeRotation(degreesToRadian(90));
landscapeTransform = CGAffineTransformTranslate(landscapeTransform, +80.00, +100.00);
myView.transform = landscapeTransform;
myView.center = CGPointMake(y / 2.00, x / 2.00);
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];