Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions src/UIKit/UIAdaptivePresentationControllerDelegate.cs
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am unsure if there is any problem with the magic that @rolfbjarne does for the protocols registration in the generator, I would double check with him first :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, there is a ProtocolMember attribute missing. Let me fix that.

{
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vey minor but param name could be just presentationController

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's the existing signature so it should stay the same

{
UIKit.UIApplication.EnsureUIThread ();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ the linker won't be able to remove the above check. I can only do so for generated code.

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
18 changes: 18 additions & 0 deletions src/UIKit/UIPopoverPresentationControllerDelegate.cs
Original file line number Diff line number Diff line change
@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same param name, again very minor

{
throw new You_Should_Not_Call_base_In_This_Method ();
}
}
}

#endif
2 changes: 2 additions & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -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 \
Expand Down
25 changes: 14 additions & 11 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -13652,35 +13654,36 @@ 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);
}

[NoTV]
[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);
}

Expand Down