From 1d56dd719595195002427b41c59c91db0f9889b5 Mon Sep 17 00:00:00 2001 From: Manuel de la Pena Date: Fri, 6 May 2016 12:21:18 +0200 Subject: [PATCH] [Fix] Add missing C# events in the UIAdaptivePresentationControllerDelegate and UIPopoverPresentationControllerDelegate classes. --- ...IAdaptivePresentationControllerDelegate.cs | 37 +++++++++++++++++++ ...UIPopoverPresentationControllerDelegate.cs | 18 +++++++++ src/frameworks.sources | 2 + src/uikit.cs | 25 +++++++------ 4 files changed, 71 insertions(+), 11 deletions(-) create mode 100644 src/UIKit/UIAdaptivePresentationControllerDelegate.cs create mode 100644 src/UIKit/UIPopoverPresentationControllerDelegate.cs diff --git a/src/UIKit/UIAdaptivePresentationControllerDelegate.cs b/src/UIKit/UIAdaptivePresentationControllerDelegate.cs new file mode 100644 index 000000000000..139e3cc0f216 --- /dev/null +++ b/src/UIKit/UIAdaptivePresentationControllerDelegate.cs @@ -0,0 +1,37 @@ +#if !WATCH +using System; +using XamCore.UIKit; +using XamCore.ObjCRuntime; +using XamCore.Foundation; + +namespace XamCore.UIKit { + public partial class UIAdaptivePresentationControllerDelegate + { + // this is a workaround to allow exposing the old API () + [Export ("adaptivePresentationStyleForPresentationController:")] + public virtual UIModalPresentationStyle GetAdaptivePresentationStyle (UIPresentationController forPresentationController) + { + throw new You_Should_Not_Call_base_In_This_Method (); + } + } + + public static partial class UIAdaptivePresentationControllerDelegate_Extensions + { + public static UIModalPresentationStyle GetAdaptivePresentationStyle (this IUIAdaptivePresentationControllerDelegate This, UIPresentationController forPresentationController) + { + UIKit.UIApplication.EnsureUIThread (); + if (forPresentationController == null) + throw new ArgumentNullException ("forPresentationController"); + UIModalPresentationStyle ret; + if (IntPtr.Size == 8) { + ret = (UIModalPresentationStyle) ObjCRuntime.Messaging.Int64_objc_msgSend_IntPtr (This.Handle, Selector.GetHandle ("adaptivePresentationStyleForPresentationController:"), forPresentationController.Handle); + } else { + ret = (UIModalPresentationStyle) ObjCRuntime.Messaging.int_objc_msgSend_IntPtr (This.Handle, Selector.GetHandle ("adaptivePresentationStyleForPresentationController:"), forPresentationController.Handle); + } + return ret; + } + } + +} + +#endif diff --git a/src/UIKit/UIPopoverPresentationControllerDelegate.cs b/src/UIKit/UIPopoverPresentationControllerDelegate.cs new file mode 100644 index 000000000000..e511de1206b1 --- /dev/null +++ b/src/UIKit/UIPopoverPresentationControllerDelegate.cs @@ -0,0 +1,18 @@ + +#if !WATCH +using XamCore.UIKit; +using XamCore.Foundation; + +namespace XamCore.UIKit { + public partial class UIPopoverPresentationControllerDelegate + { + // this is a workaround to allow exposing the old API () + [Export ("adaptivePresentationStyleForPresentationController:")] + public virtual UIModalPresentationStyle GetAdaptivePresentationStyle (UIPresentationController forPresentationController) + { + throw new You_Should_Not_Call_base_In_This_Method (); + } + } +} + +#endif diff --git a/src/frameworks.sources b/src/frameworks.sources index b97fd8caa61d..a68b5ce514b4 100644 --- a/src/frameworks.sources +++ b/src/frameworks.sources @@ -1215,6 +1215,7 @@ UIKIT_SOURCES = \ UIKit/UIActionSheet.cs \ UIKit/UIActivityItemProvider.cs \ UIKit/UIActivityViewController.cs \ + UIKit/UIAdaptivePresentationControllerDelegate.cs \ UIKit/UIAlertView.cs \ UIKit/UIAppearance.cs \ UIKit/UIApplication.cs \ @@ -1252,6 +1253,7 @@ UIKIT_SOURCES = \ UIKit/UIPickerView.cs \ UIKit/UIPopoverController.cs \ UIKit/UIPopoverPresentationController.cs \ + UIKit/UIPopoverPresentationControllerDelegate.cs \ UIKit/UIPrint.cs \ UIKit/UIPushBehavior.cs \ UIKit/UIResponder.cs \ diff --git a/src/uikit.cs b/src/uikit.cs index 43d483cbcd78..6a4af3e8ad70 100644 --- a/src/uikit.cs +++ b/src/uikit.cs @@ -13596,7 +13596,9 @@ public interface UIPopoverControllerDelegate { [NoTV] [iOS (8,0)] - [BaseType (typeof (UIPresentationController))] + [BaseType (typeof (UIPresentationController), + Delegates=new string [] {"WeakDelegate"}, + Events=new Type [] { typeof (UIPopoverPresentationControllerDelegate) })] [DisableDefaultCtor] // NSGenericException Reason: -[UIPopoverController init] is not a valid initializer. You must call -[UIPopoverController initWithContentViewController:] public partial interface UIPopoverPresentationController { // re-exposed from base class @@ -13652,18 +13654,18 @@ public partial interface UIPopoverPresentationController { [Protocol, Model] [BaseType (typeof (NSObject))] public partial interface UIAdaptivePresentationControllerDelegate { - [Export ("adaptivePresentationStyleForPresentationController:")] - UIModalPresentationStyle GetAdaptivePresentationStyle (UIPresentationController forPresentationController); - - [Export ("presentationController:viewControllerForAdaptivePresentationStyle:")] + [Export ("presentationController:viewControllerForAdaptivePresentationStyle:"), + DelegateName ("AdaptivePresentationRequestedWithStyle"), DefaultValue (null)] UIViewController GetViewControllerForAdaptivePresentation (UIPresentationController controller, UIModalPresentationStyle style); [iOS (8,3)] - [Export ("adaptivePresentationStyleForPresentationController:traitCollection:")] + [Export ("adaptivePresentationStyleForPresentationController:traitCollection:"), + DelegateName ("AdaptivePresentationStyleWithTraitsRequested"), DefaultValue (UIModalPresentationStyle.None)] UIModalPresentationStyle GetAdaptivePresentationStyle (UIPresentationController controller, UITraitCollection traitCollection); [iOS (8,3)] - [Export ("presentationController:willPresentWithAdaptiveStyle:transitionCoordinator:")] + [Export ("presentationController:willPresentWithAdaptiveStyle:transitionCoordinator:"), + DelegateName ("WillPresentController"), EventArgs ("WillPresentAdaptiveStyle")] void WillPresent (UIPresentationController presentationController, UIModalPresentationStyle style, IUIViewControllerTransitionCoordinator transitionCoordinator); } @@ -13671,16 +13673,17 @@ public partial interface UIAdaptivePresentationControllerDelegate { [Protocol, Model] [BaseType (typeof (UIAdaptivePresentationControllerDelegate))] public partial interface UIPopoverPresentationControllerDelegate { - [Export ("prepareForPopoverPresentation:")] + [Export ("prepareForPopoverPresentation:"), DelegateName ("PrepareForPresentation")] void PrepareForPopoverPresentation (UIPopoverPresentationController popoverPresentationController); - [Export ("popoverPresentationControllerShouldDismissPopover:")] + [Export ("popoverPresentationControllerShouldDismissPopover:"), DelegateName ("ShouldDismiss"), DefaultValue (true)] bool ShouldDismissPopover (UIPopoverPresentationController popoverPresentationController); - [Export ("popoverPresentationControllerDidDismissPopover:")] + [Export ("popoverPresentationControllerDidDismissPopover:"), DelegateName ("DidDismiss")] void DidDismissPopover (UIPopoverPresentationController popoverPresentationController); - [Export ("popoverPresentationController:willRepositionPopoverToRect:inView:")] + [Export ("popoverPresentationController:willRepositionPopoverToRect:inView:"), + DelegateName ("WillReposition"), EventArgs ("UIPopoverPresentationControllerReposition")] void WillRepositionPopover (UIPopoverPresentationController popoverPresentationController, ref CGRect targetRect, ref UIView inView); }