123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- //
- // Fuction_Tool.m
- // Asteria
- //
- // Created by 王猛 on 2023/5/22.
- //
- #import "Fuction_Tool.h"
- @implementation Fuction_Tool
- + (void)popToHomeVc {
- [[Current_normalTool currentNav] popToRootViewControllerAnimated:false];
- UITabBarController *tabvc = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
- if ([tabvc isKindOfClass:[UITabBarController self]]) {
- tabvc.selectedIndex = 0;
- }
- }
- + (void)popToRootViewController:(NSInteger)index {
- [[Current_normalTool currentNav] popToRootViewControllerAnimated:false];
- UITabBarController *tabvc = (UITabBarController *)[UIApplication sharedApplication].delegate.window.rootViewController;
- if ([tabvc isKindOfClass:[UITabBarController self]]) {
- tabvc.selectedIndex = index;
- }
- }
- +(void)push_BaseWebUrl:(NSString *)url webTitle:(NSString *)title{
- XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
- [vc xxx_dsWebLoadUrl:url];
- vc.webTitle = title;
- [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
- }
- +(void)push_JSBaseWebUrl:(NSString *)url webTitle:(NSString *)title{
- XXX_BaseWebC *vc = [[XXX_BaseWebC alloc] init];
- [vc xxx_dsWebLoadUrl:url];
- vc.webTitle = title;
- // [vc tool_dsWebViewAddJS];
- [[Current_normalTool topViewController].navigationController pushViewController:vc animated:true];
- }
- + (void)pop_toLoginVC {
- UIViewController *loginC = [[CTMediator sharedInstance] Login_LoginC:@{}];
- QMUINavigationController *uikitNavController = [[QMUINavigationController alloc] initWithRootViewController:loginC];
- uikitNavController.navigationBar.hidden = YES;
- uikitNavController.modalPresentationStyle = UIModalPresentationFullScreen;
- [[Current_normalTool topViewController] presentViewController:uikitNavController animated:YES completion:nil];
- }
- +(void)tool_shareImgStr:(NSString *)imgStr sharetitle:(NSString *)title shareUrl:(NSString *)urlStr currentVC:(UIViewController *)vc{
- [MBProgressHUD showHUDAddedTo:vc.view animated:YES];
- dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
- NSData * data = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:imgStr]];
- UIImage *image = [[UIImage alloc]initWithData:data];
- dispatch_async(dispatch_get_main_queue(), ^{
- //在这里做UI操作(UI操作都要放在主线程中运行)
- NSString *textToShare = title;
- NSURL *urlToShare = [NSURL URLWithString:urlStr];
- NSArray *activityItems = [NSMutableArray array];
-
- if (data != nil) {
- // activityItems = [NSMutableArray arrayWithArray:@[textToShare, image, urlToShare]];
- activityItems = [NSMutableArray arrayWithArray:@[urlToShare, image, textToShare]];
- }else{
- activityItems = [NSMutableArray arrayWithArray:@[textToShare, urlToShare]];
- }
- UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil];
- activityVC.definesPresentationContext = YES;
- activityVC.excludedActivityTypes = @[UIActivityTypeOpenInIBooks,@"com.burbn.instagram.shareextension"];
- [MBProgressHUD hideHUDForView:vc.view animated:YES];
- [vc presentViewController:activityVC animated:YES completion:nil];
- });
-
- });
-
- }
- @end
|