Skip to content

Commit

Permalink
[UIKit] Fix UIKit selector on TvOS (#18617)
Browse files Browse the repository at this point in the history
This API was missed because the old sim intro tests are not running and
we missed it. This was found while working on xcode15. The tvOS attr is
missing which defaults to the min version of tvOS when it should be 15.

Added a compat implementation so that the API remains.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
  • Loading branch information
3 people authored Aug 2, 2023
1 parent e4ed7e1 commit efd020c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
38 changes: 38 additions & 0 deletions src/UIKit/UIMenu.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#if !WATCH
using System;
using System.Runtime.InteropServices;

using ObjCRuntime;
using Foundation;

namespace UIKit {
public partial class UIMenu {
#if !XAMCORE_5_0

#if NET
[SupportedOSPlatform ("tvos15.0")]
[SupportedOSPlatform ("ios15.0")]
[SupportedOSPlatform ("maccatalyst15.0")]
#else
[iOS (15, 0)]
[TV (15,0)]
#endif
public virtual UIMenuElement [] SelectedElements {
get {
// check if we are on tvos earlier than 15, if so, return and empty array, else return
// the correct value
#if TVOS
if (SystemVersion.ChecktvOS (15, 0)) {
return _SelectedElements;
} else {
return Array.Empty<UIMenuElement> ();
}
#else
return _SelectedElements;
#endif
}
#endif
}
}
}
#endif
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -1741,6 +1741,7 @@ UIKIT_SOURCES = \
UIKit/UIKeyboard.cs \
UIKit/UIKitSynchronizationContext.cs \
UIKit/UIListSeparatorConfiguration.cs \
UIKit/UIMenu.cs \
UIKit/UINavigationBar.cs \
UIKit/UINavigationController.cs \
UIKit/UIPageViewController.cs \
Expand Down
7 changes: 6 additions & 1 deletion src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9157,9 +9157,14 @@ interface UIMenu {
[Export ("options")]
UIMenuOptions Options { get; }

[iOS (15, 0), MacCatalyst (15, 0)]
[iOS (15, 0), MacCatalyst (15, 0), TV (15, 0)]
[Export ("selectedElements")]
#if XAMCORE_5_0
UIMenuElement [] SelectedElements { get; }
#else
[Internal]
UIMenuElement [] _SelectedElements { get; }
#endif

[Export ("children")]
UIMenuElement [] Children { get; }
Expand Down

5 comments on commit efd020c

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

@vs-mobiletools-engineering-service2

This comment was marked as outdated.

Please sign in to comment.