private void ShareButtonPress() { if (ViewModel.Gist == null) { return; } var sheet = MonoTouch.Utilities.GetSheet("Gist"); var shareButton = sheet.AddButton("Share".t()); var showButton = sheet.AddButton("Show in GitHub".t()); var cancelButton = sheet.AddButton("Cancel".t()); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Clicked += (s, e) => { if (e.ButtonIndex == shareButton) { var item = UIActivity.FromObject(ViewModel.Gist.HtmlUrl); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController(activityItems, applicationActivities); PresentViewController(activityController, true, null); } else if (e.ButtonIndex == showButton) { try { UIApplication.SharedApplication.OpenUrl(new NSUrl(ViewModel.Gist.HtmlUrl)); } catch { } } }; sheet.ShowFrom(_shareButton, true); }
public void ShareTweet(Status status) { var textToSend = status.User.Name + Environment.NewLine + status.Text; var activityController = new UIActivityViewController(new NSObject[] { UIActivity.FromObject(textToSend) }, null); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(activityController, true, null); }
public static void Share(string message, UIViewController vcForUIThread, bool showInterstitial = false) { var messagecontent = message; var msg = UIActivity.FromObject(messagecontent); var item = NSObject.FromObject(msg); var activityItems = new[] { item }; var activityController = new UIActivityViewController(activityItems, null); var topController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (topController.PresentedViewController != null) { topController = topController.PresentedViewController; } if (vcForUIThread == null) { topController.PresentViewController(activityController, DeviceUtil.CanAnimate, () => { }); } else { vcForUIThread.InvokeOnMainThread(() => topController.PresentViewController(activityController, DeviceUtil.CanAnimate, () => { })); } }
partial void BtnShare_TouchUpInside(UIButton sender) { closeSheet(); var item = UIActivity.FromObject(""); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController(activityItems, applicationActivities); PresentViewController(activityController, true, null); }
private void ShareButtonCliked(object sender, EventArgs e) { var activityController = new UIActivityViewController(new NSObject[] { UIActivity.FromObject(OpentokTestConstants.ShareString), }, null); var topController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (topController.PresentedViewController != null) { topController = topController.PresentedViewController; } topController.PresentViewController(activityController, true, null); }
void Share(string msg) { //var item = NSObject.FromObject(msg); //var activityItems = new[] { item }; //var activityController = new UIActivityViewController(activityItems, null); //var topController = UIApplication.SharedApplication.KeyWindow.RootViewController; //while (topController.PresentedViewController != null) //{ // topController = topController.PresentedViewController; //} //topController.PresentViewController(activityController, true, () => { }); var activityController = new UIActivityViewController(new NSObject[] { UIActivity.FromObject(msg) }, null); UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(activityController, true, null); }
private void ShowExtraMenu() { var sheet = MonoTouch.Utilities.GetSheet(Title); var openButton = _downloadResult != null?sheet.AddButton("Open In".t()) : -1; var shareButton = sheet.AddButton("Share".t()); var showButton = _githubUrl != null?sheet.AddButton("Show in GitHub".t()) : -1; var cancelButton = sheet.AddButton("Cancel".t()); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Clicked += (s, e) => { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(_downloadResult.File); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { var item = UIActivity.FromObject(_githubUrl); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController(activityItems, applicationActivities); PresentViewController(activityController, true, null); } else if (e.ButtonIndex == showButton) { try { UIApplication.SharedApplication.OpenUrl(new NSUrl(_githubUrl)); } catch { } } }; sheet.ShowInView(this.View); }
private void ShowExtraMenu() { var sheet = MonoTouch.Utilities.GetSheet(Title); var openButton = sheet.AddButton("Open In".t()); var shareButton = ViewModel.HtmlUrl != null?sheet.AddButton("Share".t()) : -1; var showButton = ViewModel.HtmlUrl != null?sheet.AddButton("Show in Bitbucket".t()) : -1; var cancelButton = sheet.AddButton("Cancel".t()); sheet.CancelButtonIndex = cancelButton; sheet.DismissWithClickedButtonIndex(cancelButton, true); sheet.Clicked += (s, e) => { if (e.ButtonIndex == openButton) { var ctrl = new UIDocumentInteractionController(); ctrl.Url = NSUrl.FromFilename(ViewModel.FilePath); ctrl.PresentOpenInMenu(NavigationItem.RightBarButtonItem, true); } else if (e.ButtonIndex == shareButton) { var item = UIActivity.FromObject(ViewModel.HtmlUrl); var activityItems = new NSObject[] { item }; UIActivity[] applicationActivities = null; var activityController = new UIActivityViewController(activityItems, applicationActivities); PresentViewController(activityController, true, null); } else if (e.ButtonIndex == showButton) { ViewModel.GoToHtmlUrlCommand.Execute(null); } }; sheet.ShowInView(this.View); }