我正在处理应用程序,我需要将屏幕旋转 180 度。为此,我在 viewDidLoad 方法中使用此代码-
if(SYSTEM_VERSION_LESS_THAN(@"8.0"))
{
// iOS7
self.navigationController.view.transform=CGAffineTransformMakeRotation(M_PI_4*6);
}
else
{
self.navigationController.view.transform=CGAffineTransformMakeRotation(M_PI);
}
它适用于 ViewController。问题是当我尝试呈现 alertViewController 时它对我不起作用。您可以在图像中看到-
我尝试过:
[self presentViewController:alertController animated:NO completion:^{
alertController.view.transform = CGAffineTransformMakeRotation(M_PI);
}];
我也试过:
[self presentViewController:alertController animated:NO completion:^{
alertController.view.transform = CGAffineTransformMakeRotation(-M_PI*2);
}];
我正在使用这种方法来呈现 UIAlertController-
-(void) showAlertWithNoAction:(NSString *) message and:(NSString *) title
{
if ([message isEqualToString:@"" ] || message ==nil) {
message = @"Some error occured!";
}
if([UIAlertController class])
{
UIAlertController *alertController = [UIAlertController
alertControllerWithTitle:title
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction
actionWithTitle:NSLocalizedString(@"OK", @"OK action")
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action)
{
}];
[alertController addAction:okAction];
[self presentViewController:alertController animated:NO completion:^{
}];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:title
message:message
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[alert show];
}
}
正如您在屏幕截图中看到的那样,我需要在点击按钮“接受”时显示警报消息。
当 MainVC 旋转时,请帮助旋转 UIAlertViewController。