From 083976469450ef3d0a9a9df2d263b7d843e714fc Mon Sep 17 00:00:00 2001 From: Duy Tran Khanh Date: Mon, 15 May 2023 09:33:22 +0700 Subject: [PATCH] Change picker's UIMenu style --- Natives/LauncherPreferencesViewController.m | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Natives/LauncherPreferencesViewController.m b/Natives/LauncherPreferencesViewController.m index d90dd050..918ce393 100644 --- a/Natives/LauncherPreferencesViewController.m +++ b/Natives/LauncherPreferencesViewController.m @@ -22,6 +22,10 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *); @interface UIContextMenuInteraction(private) - (void)_presentMenuAtLocation:(CGPoint)location; @end +@interface _UIContextMenuStyle : NSObject +@property(nonatomic) NSInteger preferredLayout; ++ (instancetype)defaultStyle; +@end @interface LauncherPreferencesViewController(){} @property(nonatomic) UIMenu* currentMenu; @@ -779,6 +783,13 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *); }]; } +- (_UIContextMenuStyle *)_contextMenuInteraction:(UIContextMenuInteraction *)interaction styleForMenuWithConfiguration:(UIContextMenuConfiguration *)configuration +{ + _UIContextMenuStyle *style = [_UIContextMenuStyle defaultStyle]; + style.preferredLayout = 3; // _UIContextMenuLayoutCompactMenu + return style; +} + - (void)tableView:(UITableView *)tableView openPickerAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; NSDictionary *item = self.prefContents[indexPath.section][indexPath.row]; @@ -808,7 +819,8 @@ typedef void(^CreateView)(UITableViewCell *, NSString *, NSDictionary *); self.currentMenu = [UIMenu menuWithTitle:message children:menuItems]; UIContextMenuInteraction *interaction = [[UIContextMenuInteraction alloc] initWithDelegate:self]; - [cell addInteraction:interaction]; + cell.detailTextLabel.interactions = [NSArray new]; + [cell.detailTextLabel addInteraction:interaction]; [interaction _presentMenuAtLocation:CGPointZero]; }