I have an application with many views. I want only a few views to rotate horizontally when the device rotates. I found out that I cannot use (BOOL)shouldAutorotateToInterfaceOrientation , because this will rotate every view in my application. I found a solution to this problem here in Stack Overflow, but now I have another problem.
The view rotates when I rotate the device, but it still shows the view as if it was still in portrait mode (straight up and down). The top and bottom of the image are cut off. Is there a way to rotate the view, as well as adjust its size to fit the new orientation? I also found this one , but couldn't get it to work.
Here is my code for this view:
@implementation businessBank @synthesize webView, activityIndicator; - (void)viewDidLoad { [super viewDidLoad]; NSString *urlAddress = @"website_url"; NSURL *url = [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil]; } - (void)didRotate:(NSNotification *)notification { UIDeviceOrientation orientation = [[notification object] orientation]; if (orientation == UIDeviceOrientationLandscapeLeft) { [self.view setTransform:CGAffineTransformMakeRotation(M_PI / 2.0)]; } else if (orientation == UIDeviceOrientationLandscapeRight) { [self.view setTransform:CGAffineTransformMakeRotation(M_PI / -2.0)]; } else if (orientation == UIDeviceOrientationPortraitUpsideDown) { [self.view setTransform:CGAffineTransformMakeRotation(M_PI)]; } else if (orientation == UIDeviceOrientationPortrait) { [self.view setTransform:CGAffineTransformMakeRotation(0.0)]; } }
iphone resize rotation orientation
user306148
source share