Ask before casting to prevent you from accidentally hijacking the tv when you press the cast button.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

37 lines
1.5KB

  1. %hook MDXPlaybackRouteButtonController
  2. -(void)didPressButton:(id)arg1 {
  3. UIAlertController* alertController = [%c(UIAlertController) alertControllerWithTitle:@"Casting"
  4. message:@"Are you sure you want to start casting?"
  5. preferredStyle:UIAlertControllerStyleAlert];
  6. UIAlertAction* defaultAction = [%c(UIAlertAction) actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
  7. %orig;
  8. }];
  9. UIAlertAction* noButton = [%c(UIAlertAction)
  10. actionWithTitle:@"Cancel"
  11. style:UIAlertActionStyleDefault
  12. handler: ^(UIAlertAction * action) {
  13. return;
  14. }];
  15. [alertController addAction:defaultAction];
  16. [alertController addAction:noButton];
  17. id rootViewController = [%c(UIApplication) sharedApplication].delegate.window.rootViewController;
  18. if([rootViewController isKindOfClass:[%c(UINavigationController) class]]) {
  19. rootViewController = ((UINavigationController *)rootViewController).viewControllers.firstObject;
  20. }
  21. if([rootViewController isKindOfClass:[%c(UITabBarController) class]]) {
  22. rootViewController = ((UITabBarController *)rootViewController).selectedViewController;
  23. }
  24. if ([rootViewController presentedViewController] != nil) {
  25. rootViewController = [rootViewController presentedViewController];
  26. }
  27. [rootViewController presentViewController:alertController animated:YES completion:nil];
  28. }
  29. %end