English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

iOS 微信 공유 후 전송 성공 알림 끄기 및 앱 복귀

iOS에서微信에 공유한 후 앱으로 돌아가 성공적인 전송 알림을 닫고 사용자 정의 튜토리얼을 설정합니다. 구체적인 내용은 다음과 같습니다

1.성공적인 전송 알림을 닫습니다 

공유할 때 이 코드를 호출하면 됩니다:

 [UMSocialConfig setFinishToastIsHidden:YES position:UMSocialiToastPositionCenter]; 

2.사용자 정의 튜토리얼 

//앱으로 돌아가면 이 메서드가 호출됩니다
 - (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 [button 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); 
    } *operation, NSError *error) { 
    ]; 
  } 
    [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; 
} 
//어떤 영역 내에서 클릭되지 않으면 트리거되지 않고, 그렇지 않으면 트리거됨 
- )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; 
  }
}

이 문서의 모든 내용이 끝입니다. 여러분의 학습에 도움이 되길 바랍니다. 또한, 나아가는 교본을 많이 지지해 주시길 바랍니다.

좋아하는 것