Fuction_Tool.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Fuction_Tool.m
  3. // Asteria
  4. //
  5. // Created by 王猛 on 2023/5/22.
  6. //
  7. #import "Fuction_Tool.h"
  8. @implementation Fuction_Tool
  9. + (void)popToHomeVc {
  10. [[Current_normalTool currentNav] popToRootViewControllerAnimated:false];
  11. UITabBarController *tabvc = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
  12. if ([tabvc isKindOfClass:[UITabBarController self]]) {
  13. tabvc.selectedIndex = 0;
  14. }
  15. }
  16. + (void)popToRootViewController:(NSInteger)index {
  17. [[Current_normalTool currentNav] popToRootViewControllerAnimated:false];
  18. UITabBarController *tabvc = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
  19. if ([tabvc isKindOfClass:[UITabBarController self]]) {
  20. tabvc.selectedIndex = index;
  21. }
  22. }
  23. +(void)push_BaseWebUrl:(NSString *)url webTitle:(NSString *)title{
  24. XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
  25. [vc xxx_dsWebLoadUrl:url];
  26. vc.webTitle = title;
  27. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  28. }
  29. +(void)push_JSBaseWebUrl:(NSString *)url webTitle:(NSString *)title{
  30. XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
  31. [vc xxx_dsWebLoadUrl:url];
  32. vc.webTitle = title;
  33. // [vc tool_dsWebViewAddJS];
  34. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  35. }
  36. + (void)pop_toLoginVC {
  37. UIViewController *loginC = [[CTMediator sharedInstance] Login_LoginC:@{}];
  38. QMUINavigationController *uikitNavController = [[QMUINavigationController alloc] initWithRootViewController:loginC];
  39. uikitNavController.navigationBar.hidden = YES;
  40. uikitNavController.modalPresentationStyle = UIModalPresentationFullScreen;
  41. [[Current_normalTool topViewController] presentViewController:uikitNavController animated:YES completion:nil];
  42. }
  43. +(void)tool_shareImgStr:(NSString *)imgStr sharetitle:(NSString *)title shareUrl:(NSString *)urlStr currentVC:(UIViewController *)vc{
  44. [MBProgressHUD showHUDAddedTo:vc.view animated:YES];
  45. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  46. NSData * data = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imgStr]];
  47. UIImage *image = [[UIImage alloc]initWithData:data];
  48. dispatch_async(dispatch_get_main_queue(), ^{
  49. //在这里做UI操作(UI操作都要放在主线程中运行)
  50. NSString *textToShare = title;
  51. NSURL *urlToShare = [NSURL URLWithString:urlStr];
  52. NSArray *activityItems = [NSMutableArray array];
  53. if (data != nil) {
  54. // activityItems = [NSMutableArray arrayWithArray:@[textToShare, image, urlToShare]];
  55. activityItems = [NSMutableArray arrayWithArray:@[urlToShare, image, textToShare]];
  56. }else{
  57. activityItems = [NSMutableArray arrayWithArray:@[textToShare, urlToShare]];
  58. }
  59. UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
  60. activityVC.definesPresentationContext = YES;
  61. activityVC.excludedActivityTypes = @[UIActivityTypeOpenInIBooks,@"com.burbn.instagram.shareextension"];
  62. [MBProgressHUD hideHUDForView:vc.view animated:YES];
  63. [vc presentViewController:activityVC animated:YES completion:nil];
  64. });
  65. });
  66. }
  67. @end