uiwindow landscape mode problem

1.5k Views Asked by At

i a uiview compenent and add it to application uiwindow like below. it works fine in portrait mode but when i oriante into lanscape mode it does not work properly. it think uiwindow still feels itself in portrait mode although not. how can run in landscape mode?

thanks.

MyView* popupView = [[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 480) url:url slidingType:slidingType html5Flag:_html5Flag];
// i change frame to CGRectMake(0, 0,480, 320) but not works

[popupView setTitle:self.currentAd.altText];
popupView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5]; 

UIWindow* mainWindow = (((UIWindow*) [UIApplication sharedApplication].delegate).window);   

CGPoint middleCenter = popupView.center;   
CGSize offSize = [UIScreen mainScreen].bounds.size;  

CGPoint offScreenCenter = CGPointMake(offSize.width / 2.0, offSize.height * 1.5);   

popupView.center = offScreenCenter; 
[mainWindow addSubview:popupView];    
popupView.center = middleCenter;
1

There are 1 best solutions below

1
On

Is that you view popupView autorized to rotate ? You need yo implement this method in your UIViewController class:

- (void)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation {
    return YES;
}