Rotating a UIAlertView

旧时模样 提交于 2019-12-19 02:27:21

问题


I've created a custom UIAlertView (by subclassing it and messing around with its show function) that has some custom subviews and is of non-standard size.

It works ok when I create and display it, however, when the device is rotated, the alert rotates and then returns to its default size.

Any ideas what functions to override - or should I tweak the UIViewController?

thanks, Peter


回答1:


Not sure if force rotating the UIAlertView fits the Apple GUI guidelines, but you can rotate it by defining the status bar (status bar and UIAlertView sticks together)

application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
application.statusBarOrientation = UIInterfaceOrientationLandscapeLeft;

But UIAlertView is a UIView just like many others, so try this :

- (void)didPresentAlertView:(UIAlertView *)alertView
{
    [UIView beginAnimations:@"" context:nil];
    [UIView setAnimationDuration:0.1];
    alertView.transform = CGAffineTransformRotate(alertView.transform, degreesToRadian(90));
    [UIView commitAnimations];
}


来源:https://stackoverflow.com/questions/6859438/rotating-a-uialertview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!