我的UIAlertView不是从开始旋转到横向模式

时间:2012-12-19 15:24:35

标签: rotation uialertview landscape

我在这个网站上发现了很多类似的问题,但是他们都没有完全解决我的问题。

我的ViewController处于横向模式,我希望我的UIAlertView以相同的模式显示。我在这里找到了一些答案,但只有在以纵向模式显示后才会旋转UIAlertView。

这是我使用的代码:

 - (void)didPresentAlertView:(UIAlertView *)alertView
 {
 // UIAlertView in landscape mode

 [UIView beginAnimations:@"" context:nil];
 [UIView setAnimationDuration:0.1];
 alertView.transform = CGAffineTransformRotate(alertView.transform, 3.14159/2);
 [UIView commitAnimations];
 }

为了将UIViewController旋转到横向模式,我使用了以下代码:

 - (BOOL)shouldAutorotate {

UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];

if (orientation==UIInterfaceOrientationLandscapeRight) {
    // do some sh!t
}

return YES;
}

-(NSUInteger)supportedInterfaceOrientations{
   return UIInterfaceOrientationMaskLandscapeRight;
}

0 个答案:

没有答案
相关问题