I have created a UIView.I want to subview the view to the appdelegate wind
if we add any object to window and then we want to change the orientation then we must use transform methods.
#define DegreesToRadians(degrees) (degrees *M_PI /180)
add above line
CGAffineTransform newTransform;
UIDeviceOrientation orientation = [UIDevice currentDevice].orientation;
switch (orientation)
{
case UIInterfaceOrientationPortraitUpsideDown:
newTransform = CGAffineTransformMakeRotation(-DegreesToRadians(180));
txt.transform = newTransform;
txt.frame = CGRectMake(0, 0, 320, 480);
break;
case UIInterfaceOrientationLandscapeLeft:
newTransform = CGAffineTransformMakeRotation(DegreesToRadians(-90));
txt.transform = newTransform;
txt.frame = CGRectMake(0, 0, 320, 480);
break;
case UIInterfaceOrientationLandscapeRight:
newTransform = CGAffineTransformMakeRotation(DegreesToRadians(90));
txt.transform = newTransform;
txt.frame = CGRectMake(0, 0, 320, 480);
break;
default:
newTransform = CGAffineTransformMakeRotation(-DegreesToRadians(0));
txt.transform = newTransform;
txt.frame = CGRectMake(0, 0, 320, 480);
break;
}
here txt is object name,try in this way.