void SetupActivityCompletion() { if (activityViewController == null) { return; } activityViewController.SetCompletionHandler((aType, completed, items, aError) => CleanupActivity()); }
public void OnShareClicked(UIBarButtonItem button) { UIActivityViewController activityViewController = new UIActivityViewController (new NSObject[] { ImageView.Image }, null); var popover = activityViewController.PopoverPresentationController; if (popover != null) { popover.BarButtonItem = ShareItem; } // Set a completion handler to handle what the UIActivityViewController returns activityViewController.SetCompletionHandler ((activityType, completed, returnedItems, error) => { if (returnedItems == null || returnedItems.Length == 0) return; NSExtensionItem extensionItem = returnedItems [0]; NSItemProvider imageItemProvider = extensionItem.Attachments [0]; if (!imageItemProvider.HasItemConformingTo(UTType.Image)) return; imageItemProvider.LoadItem (UTType.Image, null, (item, loadError) => { if (item != null && loadError == null) InvokeOnMainThread (() => { ImageView.Image = (UIImage)item; }); }); }); PresentViewController (activityViewController, true, null); }
public void OnShareClicked(UIBarButtonItem button) { UIActivityViewController activityViewController = new UIActivityViewController(new NSObject[] { ImageView.Image }, null); var popover = activityViewController.PopoverPresentationController; if (popover != null) { popover.BarButtonItem = ShareItem; } // Set a completion handler to handle what the UIActivityViewController returns activityViewController.SetCompletionHandler((activityType, completed, returnedItems, error) => { if (returnedItems == null || returnedItems.Length == 0) { return; } NSExtensionItem extensionItem = returnedItems [0]; NSItemProvider imageItemProvider = extensionItem.Attachments [0]; if (!imageItemProvider.HasItemConformingTo(UTType.Image)) { return; } imageItemProvider.LoadItem(UTType.Image, null, (item, loadError) => { if (item != null && loadError == null) { InvokeOnMainThread(() => { ImageView.Image = (UIImage)item; }); } }); }); PresentViewController(activityViewController, true, null); }
async partial void actionClicked (UIBarButtonItem sender) { var annotatedImage = AnnotateView.IncrementImage; if (annotatedImage != null) { var firstActivityItem = annotatedImage.AsJPEG(1); var applicationActivities = new List<UIActivity> (); // var donedoneActivity = BtTrackerActivity(TrackerType.DoneDone); applicationActivities.Add(new BtTrackerActivity (TrackerType.DoneDone)); applicationActivities.Add(new BtTrackerActivity (TrackerType.PivotalTracker)); applicationActivities.Add(new BtTrackerActivity (TrackerType.JIRA)); var activityViewController = new UIActivityViewController (new [] { firstActivityItem }, applicationActivities.ToArray()); activityViewController.ExcludedActivityTypes = new [] { UIActivityType.PostToWeibo, UIActivityType.AddToReadingList, UIActivityType.PostToVimeo, UIActivityType.PostToTencentWeibo }; // This doesn't get called for the custom activities (BtTrackerActivity) activityViewController.SetCompletionHandler((activityType, completed, returnedItems, error) => { if (completed) { // if (activityType != null) Analytics.Shared.Activity(activityType.ToString(), true); Console.WriteLine("{0} -- Completed", activityType); } else if (error != null) { Console.WriteLine(error.LocalizedDescription); //Log.Error("UIActivityViewController", error.LocalizedDescription); } else if (activityType != null) { Console.WriteLine("{0} -- Cancelled", activityType); // Analytics.Shared.Activity(activityType.ToString(), false); } }); // set the action but as the popover's anchor for ipad if (activityViewController.PopoverPresentationController != null) { activityViewController.PopoverPresentationController.BarButtonItem = actionButton; } // has the image been altered? if (AnnotateView.ImageHasChanges) await TrapState.Shared.UpdateActiveSnapshotImage(annotatedImage); NavigationController.PresentViewController(activityViewController, true, null); } }
private void OnShareClicked(object sender, EventArgs ea) { if (_shareController == null) { var activityController = new UIActivityViewController(new NSObject[] { _imageView.Image }, null); activityController.SetCompletionHandler( (activityType, completed, returnedItems, error) => { _shareController = null; }); _shareController = new UIPopoverController(activityController); _shareController.DidDismiss += (s, e) => _shareController = null; _shareController.PresentFromBarButtonItem(_btShare, UIPopoverArrowDirection.Up, true); } else { _shareController.Dismiss(true); _shareController = null; } }
private async void OnShareClicked(object sender, EventArgs ea) { if (_shareController == null) { List<UIImage> images = await GetSharedImages(); if (images.IsNullOrEmpty()) { return; } var activityController = new UIActivityViewController(images.ToArray(), null); activityController.SetCompletionHandler( (activityType, completed, returnedItems, error) => { if (completed) { OnTagSelectorCancel(); } _shareController = null; }); _shareController = new UIPopoverController(activityController); _shareController.DidDismiss += (s, e) => { _shareController = null; }; _shareController.PresentFromBarButtonItem(_btShare, UIPopoverArrowDirection.Up, true); } else { _shareController.Dismiss(true); _shareController = null; } }