Fuction_Tool.m 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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)push_BaseWebUrl:(NSString *)url webTitle:(NSString *)title{
  17. XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
  18. [vc xxx_dsWebLoadUrl:url];
  19. vc.webTitle = title;
  20. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  21. }
  22. +(void)push_JSBaseWebUrl:(NSString *)url webTitle:(NSString *)title{
  23. XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
  24. [vc xxx_dsWebLoadUrl:url];
  25. vc.webTitle = title;
  26. // [vc tool_dsWebViewAddJS];
  27. [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
  28. }
  29. + (void)pop_toLoginVC {
  30. UIViewController *loginC = [[CTMediator sharedInstance] Login_LoginC:@{}];
  31. QMUINavigationController *uikitNavController = [[QMUINavigationController alloc] initWithRootViewController:loginC];
  32. uikitNavController.navigationBar.hidden = YES;
  33. uikitNavController.modalPresentationStyle = UIModalPresentationFullScreen;
  34. [[Current_normalTool topViewController] presentViewController:uikitNavController animated:YES completion:nil];
  35. }
  36. +(void)tool_shareImgStr:(NSString *)imgStr sharetitle:(NSString *)title shareUrl:(NSString *)urlStr currentVC:(UIViewController *)vc{
  37. [MBProgressHUD showHUDAddedTo:vc.view animated:YES];
  38. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  39. NSData * data = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imgStr]];
  40. UIImage *image = [[UIImage alloc]initWithData:data];
  41. dispatch_async(dispatch_get_main_queue(), ^{
  42. //在这里做UI操作(UI操作都要放在主线程中运行)
  43. NSString *textToShare = title;
  44. NSURL *urlToShare = [NSURL URLWithString:urlStr];
  45. NSArray *activityItems = [NSMutableArray array];
  46. if (data != nil) {
  47. // activityItems = [NSMutableArray arrayWithArray:@[textToShare, image, urlToShare]];
  48. activityItems = [NSMutableArray arrayWithArray:@[urlToShare, image, textToShare]];
  49. }else{
  50. activityItems = [NSMutableArray arrayWithArray:@[textToShare, urlToShare]];
  51. }
  52. UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
  53. activityVC.definesPresentationContext = YES;
  54. activityVC.excludedActivityTypes = @[UIActivityTypeOpenInIBooks,@"com.burbn.instagram.shareextension"];
  55. [MBProgressHUD hideHUDForView:vc.view animated:YES];
  56. [vc presentViewController:activityVC animated:YES completion:nil];
  57. });
  58. });
  59. }
  60. @end