Is it possible to rotate UIAlertController (and Alert) in landscape orientation?

I am editing an application where I added a new UIViewController to configure multiplayer games in one layout.

I added two buttons for each player (top button, bot button). Each button generates a warning on the screen (remember that it is in landscape orientation), but the problem is that player 2 does not see that the warning is turned, I mean that the warning should be displayed in its orientation, in front of me.

How can I do that? I want to turn a warning for player 2, will not see the notification information.

Here is the warning code I have:

@IBAction func ShowAlert(){
let message = "Test"
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)

let action = UIAlertAction(title: "OK", style: .Default, handler: nil)

    alert.addAction(action)

    presentViewController(alert, animated: true, completion: nil)
}
+4
2

, . , , .

"" , hidden, , ​​".

let alert // setup

alert.view.hidden = true;
[self presentViewController:c animated:YES completion:^{
    alert.view.transform = CGAffineTransformMakeRotation(M_PI);
    alert.view.hidden = false;
}];

, , , , , ( ). , , - .


, "" , . , .

+8

. presentViewController , .

[self presentViewController:alert animated:NO completion:^{
    [alertController.view setTransform: CGAffineTransformMakeRotation(M_PI_2)];
 }];

UIAlertController , . UIAlertController+Orientation viewWillDisappear, -- .

#import "UIAlertController+Orientation.h"

@implementation UIAlertController (Orientation)

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    [self.view setHidden:YES];
}

- (BOOL) shouldAutorotate {
    return NO;
}

@end
0

Source: https://habr.com/ru/post/1610121/


All Articles