Questions tagged [uimenu]

50 questions
29
votes
4 answers

How to modify UIMenu before it's shown to support dynamic actions

iOS 14 adds the ability to display menus upon tapping or long pressing a UIBarButtonItem or UIButton, like so: let menu = UIMenu(children: [UIAction(title: "Action", image: nil) { action in //do something }]) button.menu = menu barButtonItem =…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
12
votes
3 answers

Show UIMenu when single-tapping UIBarButtonItem

in iOS 14, there are new APIs for UIMenu, and it can now be attached to UIBarButtonItem, just like that: This is my code: @IBOutlet weak var addButton: UIBarButtonItem! // The button is from the storyboard. override func viewDidAppear(_ animated:…
אורי orihpt
  • 2,358
  • 2
  • 16
  • 41
11
votes
1 answer

How to change text and background color UIMenu | UIAction (Swift 5)

Please tell me how to customize this menu? Perhaps another way to do it? let barMenu = UIMenu(title: "", children: [ UIAction(title: NSLocalizedString("menu_item_home", comment: "")){ action in …
IamFromUSSR
  • 121
  • 5
10
votes
3 answers

Change the location of an UImenu in swift

I want to add an UIMenu to my application, I was practicing with it and now have the question if is possible to set the location of the UIMenu a little higher than the button is currently displaying it: as you can see in this photo the menu…
Ricardo Guerrero
  • 433
  • 1
  • 5
  • 21
9
votes
2 answers

buildMenu is called in AppDelegate but not UIViewController

I'm attempting to create a custom menu for each view in my app, however it appears buildMenu is not being called in View Controllers. Here's an example: In my AppDelegate, this code is used, which works 100% as expected. override func buildMenu(with…
Dave
  • 91
  • 1
  • 3
7
votes
1 answer

iOS 14 present UIMenu from UIView

iOS 14's UIMenu seems to be able to be presented from any UIBarButtonItem or UIButton / UIControl, but I how would I present it from a generic UIView?
Joel Fischer
  • 6,521
  • 5
  • 35
  • 46
6
votes
2 answers

How to manually change the selected UIAction inside UIMenu?

The Goal: Trying to create a filter selection screen (in a card view) that has UIButtons with UIMenu items attached them. When i select any of the filters, and click on the apply filters button, i dismiss the filter view controller and go back to…
GameDev
  • 445
  • 7
  • 21
6
votes
0 answers

How to programmatically trigger UIMenu from UIViewRepresentable

I tried to create a custom SwiftUI menu (based on UIMenu). However, I'm unable to trigger the primary action. It works when I tap on the CustomMenu but the programmatic action is not triggered. What am I doing wrong? struct CustomMenu:…
pawello2222
  • 46,897
  • 22
  • 145
  • 209
5
votes
1 answer

iOS 14 UIMenu replacingChildren does not work

I want to add an UIMenu with conditional menu children to a UIButton's menu on iOS14, but the replacingChildren does not work. self.button.menu = UIMenu( options: .displayInline, children:[ UIAction(title:"Action 1"){_ in}, …
Des
  • 147
  • 2
  • 8
4
votes
1 answer

How to use a pull down menu with storyboard

I'm trying to use a pull down menu in my app using the storyboard but I keep getting an error saying "Menu does not have a valid element for default selection". My setup looks like this: I've successfully managed to implement a pull down menu using…
Dennis
  • 53
  • 4
4
votes
0 answers

How to change UIMenu alignment and font in Swift?

I want to change UIMenu alignment and font. There is a identifier in UIMenu open class UIMenu : UIMenuElement { /// Unique identifier. open var identifier: UIMenu.Identifier { get } } And there is a extension for it extension…
Fattaneh Talebi
  • 727
  • 1
  • 16
  • 42
4
votes
1 answer

How to tell when a UIMenu gets DISMISSED

I have a UIButton with a UIMenu attached, I need to know when the UIMenu is dismissed (by tapping outside the UIMenu) so I can remove the button that the UIMenu is attached to. I have seen there are notifications for UIMenuController, but that is…
Ungrace
  • 214
  • 2
  • 12
4
votes
2 answers

How do I present a pull-down menu?

I'm looking to add a pull-down menu and I have no idea where to start. Apple's website guides me to UIMenu but I can't figure out how it works. I know how to make a UIMenu: NSMutableArray* actions = [[NSMutableArray alloc] init]; [actions…
Vulkan
  • 1,004
  • 16
  • 44
4
votes
0 answers

Is there any way to add a UIMenu to a UIView?

I need to add UIMenu (dropdown) to a custom UIView and there is no such option. I have this option on buttons but I really need it on a view. func createMenu() -> UIMenu{ let destruct = UIAction(title: "Destruct", attributes: .destructive) {…
maxh
  • 79
  • 4
4
votes
2 answers

iOS 14 setup the UIBarButttonItem menu before it is opened

As iOS14 offers an easy way to setup the menu on the UIBarButtonItem, I wonder do I miss that there is no easy way to setup its items as they may depend on the current context. I see that there is UIDeferredMenuElement, but this doesn't seem to be a…
Ivan Ičin
  • 9,672
  • 5
  • 36
  • 57
1
2 3 4