最近 在竖屏绘制横屏界面,里面的系统对话框 如何旋转,一直需要研究。我找到了这段代码,给大家解读下。下载地址见文末URL。
首先,旋转必须在推送完成后。代码如下:
UIAlertController *alertView = [UIAlertController alertControllerWithTitle:@"旋转" message:@"alert强制旋转" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
[alertView addAction:cancelAction];
UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:nil];
[alertView addAction:sureAction];
alertView.view.hidden = YES;
[self presentViewController:alertView animated:YES completion:^{
//实现旋转 写其他位置 不生效
alertView.view.transform = CGAffineTransformMakeRotation(M_PI_2);
alertView.view.hidden = NO;
}];
但是只是这样,还是会有问题。可以看到旋转前的情况,或者操作后,会出现旋