当前位置: 首页 > 编程笔记 >

iOS微信分享后关闭发送成功提示并返回应用

暨成双
2023-03-14
本文向大家介绍iOS微信分享后关闭发送成功提示并返回应用,包括了iOS微信分享后关闭发送成功提示并返回应用的使用技巧和注意事项,需要的朋友参考一下

iOS 分享到微信之后返回应用关闭发送成功的提示,并自定义提示,具体内容如下

1.关闭发送成功的提示 

只要在分享的时候调用一下代码即可:

 [UMSocialConfig setFinishToastIsHidden:YES  position:UMSocialiToastPositionCenter]; 

2.自定义提示 

//如果点击返回app会调用这个方法
 - (void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response {
   //返回200说明分享成功 
  if (response.responseCode == 200) { 
      //分享成功之后弹出这个提示语 
 
      //自己添加遮罩层,并添加点击手势,方便回收提示 
      self.mask2 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_Width, kScreen_Height)]; 
      self.mask2.backgroundColor = [[UIColor colorWithHexColorString:@"000000"] colorWithAlphaComponent:0.5]; 
      UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap:)]; 
      [self.mask2 addGestureRecognizer:tap]; 
      [self.view.window addSubview:self.mask2];
     //遮罩层上放提示框      
      self.showView = [[UIView alloc] init]; 
      self.showView.frame = CGRectMake(32, kScreen_Height/2.0-((kScreen_Width-64)/254.0*150.0+44)/2.0-20, kScreen_Width-64, 0);
      self.showView.backgroundColor = [UIColor whiteColor]; 
      self.showView.layer.cornerRadius = 20; 
      [self.mask2 addSubview:_showView];
 
      
 
      UILabel *titleLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, _showView.width, 31)]; 
      titleLab.text = @"分享成功"; 
      titleLab.textAlignment = NSTextAlignmentCenter; 
      titleLab.backgroundColor = [UIColor redColor]; 
      titleLab.textColor = [UIColor whiteColor]; 
      titleLab.font = [UIFont systemFontOfSize:15]; 
     //使用贝塞尔曲线,绘制一个上面两个是圆角的矩形 
      UIBezierPath *titlePath = [UIBezierPath bezierPathWithRoundedRect:titleLab.bounds byRoundingCorners:UIRectCornerTopLeft|UIRectCornerTopRight cornerRadii:CGSizeMake(20, 20)]; 
      CAShapeLayer *titleLayer = [CAShapeLayer layer]; 
      titleLayer.frame = titleLab.bounds; 
      titleLayer.path = titlePath.CGPath; 
      titleLab.layer.mask = titleLayer; 
      [_showView addSubview:titleLab]; 
 
      UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(16, 31+16, _showView.width-32, 15)]; 
      lab.textAlignment = NSTextAlignmentLeft;
       lab.text = @"大家都在看"; 
      lab.textColor = [UIColor colorWithHexColorString:@"000000"]; 
      lab.font = [UIFont systemFontOfSize:15]; 
      [_showView addSubview:lab];
 
      
 
      NSMutableArray *arr = [[NSMutableArray alloc] initWithObjects:@"",@"" nil]; 
      int y = 31+16+15+16; 
      for (int i = 0; i<arr.count; i++) {
 
        UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom]; 
        CGSize size = [self getStringSize:arr[i] andFont:13 andWidth:self.showView.width-32]; 
        button1.tag = 600+i; 
        button1.frame = CGRectMake(16, y, _showView.width-32, size.height); 
        [button1 setTitle:arr[i] forState:UIControlStateNormal]; 
        button1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; 
        [button1 setTitleColor:[UIColor colorWithHexColorString:@"0096ff"] forState:UIControlStateNormal]; 
        button1.titleLabel.font = [UIFont systemFontOfSize:13]; 
        [button1 addTarget:self action:@selector(button1Click:) forControlEvents:UIControlEventTouchUpInside]; 
        button1.titleLabel.numberOfLines = 0; 
        [_showView addSubview:button1]; 
        y+=size.height+16;
         if (i+1!=arr.count) { 
          UIView *line = [[UIView alloc] initWithFrame:CGRectMake(16, y, self.showView.width-32, 0.5)]; 
          line.backgroundColor = [UIColor colorWithHexColorString:@"f0f0f0"]; 
          [_showView addSubview:line]; 
          y+=0.5+16;
 
        }
 
        
 
      }
 
      self.showView.frame = CGRectMake(32, kScreen_Height/2.0-((kScreen_Width-64)/254.0*150.0+44)/2.0-20, kScreen_Width-64, y+16); 
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) { 
    }]; 
  }else{ 
    [MBProgressHUD showError:@"分享失败"]; 
  }
 
}
 
 
 
//获取字符串的长度 
-(CGSize)getStringSize:(NSString*)needString andFont:(CGFloat)font andWidth:(NSInteger)width
 
{ 
  CGSize size = CGSizeZero; 
  size = [needString boundingRectWithSize:CGSizeMake(width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:font]} context:nil].size; 
  return size; 
} 
//若点击在某个区域之内不触发,否则触发 
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 
  if ([touch.view isDescendantOfView:self.showView]) { 
    return NO; 
  }else { 
    return YES 
    ; 
  } 
} 
- (void)tap:(UITapGestureRecognizer *)sender {
 
  [self.mask2 removeFromSuperview];
 
} 
- (void)button1Click:(UIButton *)sender { 
  [self.mask2 removeFromSuperview]; 
  switch (sender.tag) { 
    case 600: 
    {
     }
       break;
     case 601:
 
    { 
    } 
      break; 
    default: 
      break; 
  }
 
}

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持小牛知识库。

 类似资料:
  • 本文向大家介绍iOS 微信分享功能简单实现,包括了iOS 微信分享功能简单实现的使用技巧和注意事项,需要的朋友参考一下 PS:此文以简单实现功能为主,不足之前还望指点,大神勿喷. 在此之前如何申请微信认证的Key就不说了,公司一般会有人搞(自己申请一个也非常的简单) 1.首先下载微信SDK:微信SDK下载地址(更多关于微信SDK信息文档请访问官方网站:微信开放平台) 2.导入微信SDK 将下载下来

  • 本文向大家介绍iOS实现微信分享多张图片功能,包括了iOS实现微信分享多张图片功能的使用技巧和注意事项,需要的朋友参考一下 前言 微信分享到朋友圈,可分享的类型有:文字类型、图片类型、音乐类型、视频类型和网页类型,但是我们在做图片分享的时候发现微信给的API只能分享一张图片,达不到一些APP的需求,而产品汪或者Boss想要分享多张图片,比如前段时间我做的一个APP,是电商类APP,想把商品的图片都

  • 本文向大家介绍vue单应用在ios系统中实现微信分享功能操作,包括了vue单应用在ios系统中实现微信分享功能操作的使用技巧和注意事项,需要的朋友参考一下 表示是第一次使用vue做单应用显目,也是在逐渐的摸索中~更是各种踩坑,各种填坑,打算写博客么?是因为不想写笔记了,嗯嗯 就是这么简单 进入正题。 刚开始做微信分享的这个功能的时候,脑补了官方文档微信JS-SDK说明文档 基础的知识不多说了,反正

  • 本文向大家介绍完整的iOS新浪微博分享功能开发,包括了完整的iOS新浪微博分享功能开发的使用技巧和注意事项,需要的朋友参考一下 本文实例为大家分享了iOS新浪微博分享功能的具体代码,供大家参考,具体内容如下 做新浪分享 需先去http://open.weibo.com/apps注册开发者app 很简单! 第1步 第2步 3 设置你的应用的信息 找到自己的appkey 还需要设置自己的kAppRed

  • 我正在为离我很远的人开发一个应用程序。我在用Android Studio。我的老板想在他们的手机上试用这个应用程序,但是我的老板没有android studio,也不知道如何使用Git。我如何在他们的手机上获得应用程序?有没有一种方法可以访问应用程序文件,以便它们可以很容易地放在手机上?

  • 本文向大家介绍iOS集成微信支付开发,包括了iOS集成微信支付开发的使用技巧和注意事项,需要的朋友参考一下 本文实例为大家分享了iOS集成微信支付开发代码,供大家参考,具体内容如下 首先需要理清楚流程: 1、用户使用APP客户端,选择商品下单。 2、商户客户端(就是你做的APP)将用户的商品数据传给商户服务器,请求生成支付订单。 3、商户后台调用统一下单API向微信的服务器发送请求,微信服务器生成