Equivalent to AppleTV UIAlertView

So, I'm working on buying an application in SpriteKit on AppleTV, but in the case of a payment error or any other variety of errors, I want to show an error. UIAlertView is how I did it on iOS, but it is not an option for tvOS. Is there something similar that could be done instead? Basically, I need something to pop up describing the error and a button to reject the popup. The ability to add additional buttons (for example, UIAlertView) would be icing.

Note. I studied this a bit, and most things seem to indicate the use of TVML, however I do not believe that there is an option in SpriteKit. I will agree to an answer related to this if it explains how to import something TVML (which I know nothing about) and run it along with SpriteKit. I assume that I am looking for an answer not related to TVML.

+4
source share
1 answer

Check tvOS class UIAlertController:

UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
                           message:@"This is an alert."
                           preferredStyle:UIAlertControllerStyleAlert];


UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
   handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];

Edit: when using SpriteKit, the last line is replaced by

UIViewController* controller = [UIApplication sharedApplication].keyWindow.rootViewController;
[controller presentViewController:alert animated:YES completion:nil];

Please note that this class is also available on iOS with iOS 8!

+16
source

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


All Articles