修改分享方式
This commit is contained in:
@@ -128,9 +128,12 @@
|
|||||||
if (!self.viewModel) {
|
if (!self.viewModel) {
|
||||||
self.viewModel = [[KBMyVM alloc] init];
|
self.viewModel = [[KBMyVM alloc] init];
|
||||||
}
|
}
|
||||||
|
__weak typeof(self) weakSelf = self;
|
||||||
[KBHUD show];
|
[KBHUD show];
|
||||||
[self.viewModel fetchInviteCodeWithCompletion:^(KBInviteCodeModel * _Nullable inviteCode, NSError * _Nullable error) {
|
[self.viewModel fetchInviteCodeWithCompletion:^(KBInviteCodeModel * _Nullable inviteCode, NSError * _Nullable error) {
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
__strong typeof(weakSelf) self = weakSelf;
|
||||||
|
if (!self) { return; }
|
||||||
[KBHUD dismiss];
|
[KBHUD dismiss];
|
||||||
if (error) {
|
if (error) {
|
||||||
[KBHUD showInfo:error.localizedDescription ?: KBLocalized(@"Network error")];
|
[KBHUD showInfo:error.localizedDescription ?: KBLocalized(@"Network error")];
|
||||||
@@ -143,8 +146,20 @@
|
|||||||
return;
|
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;
|
UIPasteboard.generalPasteboard.string = textToCopy;
|
||||||
[KBHUD showInfo:KBLocalized(@"Copy Success")];
|
[self presentViewController:activityVC animated:YES completion:nil];
|
||||||
});
|
});
|
||||||
}];
|
}];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user