diff --git a/keyBoard/Class/Me/VC/MyVC.m b/keyBoard/Class/Me/VC/MyVC.m index 02c4519..baa45dd 100644 --- a/keyBoard/Class/Me/VC/MyVC.m +++ b/keyBoard/Class/Me/VC/MyVC.m @@ -128,9 +128,12 @@ if (!self.viewModel) { self.viewModel = [[KBMyVM alloc] init]; } + __weak typeof(self) weakSelf = self; [KBHUD show]; [self.viewModel fetchInviteCodeWithCompletion:^(KBInviteCodeModel * _Nullable inviteCode, NSError * _Nullable error) { dispatch_async(dispatch_get_main_queue(), ^{ + __strong typeof(weakSelf) self = weakSelf; + if (!self) { return; } [KBHUD dismiss]; if (error) { [KBHUD showInfo:error.localizedDescription ?: KBLocalized(@"Network error")]; @@ -142,9 +145,21 @@ [KBHUD showInfo:KBLocalized(@"Failed")]; return; } - + + id shareItem = textToCopy; + NSURL *url = [NSURL URLWithString:textToCopy]; + if (url) { + shareItem = url; + } + UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:@[shareItem] applicationActivities:nil]; + UIPopoverPresentationController *popover = activityVC.popoverPresentationController; + if (popover) { + popover.sourceView = self.view; + popover.sourceRect = CGRectMake(CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds), 1, 1); + popover.permittedArrowDirections = 0; + } UIPasteboard.generalPasteboard.string = textToCopy; - [KBHUD showInfo:KBLocalized(@"Copy Success")]; + [self presentViewController:activityVC animated:YES completion:nil]; }); }];