UIViewController+VLCAlert.m 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*****************************************************************************
  2. * VLC for iOS
  3. *****************************************************************************
  4. * Copyright (c) 2015 VideoLAN. All rights reserved.
  5. * $Id$
  6. *
  7. * Authors: Tobias Conradi <videolan # tobias-conradi.de>
  8. *
  9. * Refer to the COPYING file of the official project for license.
  10. *****************************************************************************/
  11. #import "UIViewController+VLCAlert.h"
  12. #import "VLC_iOS-Swift.h"
  13. @implementation UIViewController (UIViewController_VLCAlert)
  14. #if TARGET_OS_TV
  15. - (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle
  16. {
  17. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
  18. [alertController addAction:[UIAlertAction actionWithTitle:buttonTitle style:UIAlertActionStyleDefault handler:nil]];
  19. [self presentViewController:alertController animated:YES completion:nil];
  20. }
  21. #else
  22. - (void)vlc_showAlertWithTitle:(NSString *)title message:(NSString *)message buttonTitle:(NSString *)buttonTitle
  23. {
  24. NSMutableArray<ButtonAction *> *buttonsAction = [[NSMutableArray alloc] init];
  25. ButtonAction *cancelAction = [[ButtonAction alloc] initWithButtonTitle: buttonTitle
  26. buttonAction: ^(UIAlertAction* action){}];
  27. [buttonsAction addObject: cancelAction];
  28. [VLCAlertViewController alertViewManagerWithTitle:title
  29. errorMessage:message
  30. viewController:self
  31. buttonsAction:buttonsAction];
  32. }
  33. #endif
  34. @end