我可以在Xamarin.IOS中调用此对话框吗?

时间:2017-10-04 09:16:19

标签: ios xamarin.ios

这是一个可以在IOS中调用的内置对话框,还是可以使用UIActivityViewController手动编写它?

enter image description here

1 个答案:

答案 0 :(得分:0)

来自ActionSheet

UIAlertController

// Create a new Alert Controller
                UIAlertController actionSheetAlert = UIAlertController.Create("Action Sheet", "Select an item from below", UIAlertControllerStyle.ActionSheet);

                // Add Actions
                actionSheetAlert.AddAction(UIAlertAction.Create("Item One",UIAlertActionStyle.Default, (action) => Console.WriteLine ("Item One pressed.")));

                actionSheetAlert.AddAction(UIAlertAction.Create("Item Two",UIAlertActionStyle.Default, (action) => Console.WriteLine ("Item Two pressed.")));

                actionSheetAlert.AddAction(UIAlertAction.Create("Item Three",UIAlertActionStyle.Default, (action) => Console.WriteLine ("Item Three pressed.")));

                actionSheetAlert.AddAction(UIAlertAction.Create("Cancel",UIAlertActionStyle.Cancel, (action) => Console.WriteLine ("Cancel button pressed.")));

                // Required for iPad - You must specify a source for the Action Sheet since it is
                // displayed as a popover
                UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController;
                if (presentationPopover!=null) {
                    presentationPopover.SourceView = this.View;
                    presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up;
                }

                // Display the alert
                this.PresentViewController(actionSheetAlert,true,null);

更多信息:https://developer.xamarin.com/recipes/ios/standard_controls/alertcontroller/