开发者

Rotating a UIAlertView

开发者 https://www.devze.com 2023-03-23 18:30 出处:网络
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.

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 rota开发者_C百科tes and then returns to its default size.

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

thanks, Peter


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];
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号