Wednesday, December 7, 2022
HomeiOS Developmentios - Swift: Find out how to hook up "Pop Up Button"...

ios – Swift: Find out how to hook up “Pop Up Button” occasion handler on choice replace?

Howdy I added a “Pop Up Button” from XCode Object Library, and wished to hook it up with occasion handler that handles menu merchandise choice replace (for app’s language choice).

The button is already created in *.xib file, and what sort of perform ought to I create to hook up with button occasions?

I created a IBAction handler like this:

@IBOutlet weak var languageSettingButton: UIButton!

@IBAction func onLanguageSelected() {
    // dealing with choice
    // ...

However dragging the selector to this IBAction perform didn’t work. What sort of selector perform is it anticipating? How do I hook it up?


My utilization with two menu choices relating to two app languages:

enter image description here

The Pop Up Button:

enter image description here


Adopted @Charles Srstka’s remark:

The IBAction func must have a sender param:

@IBAction func onLanguageSelected(_ sender: Any?) {

Nevertheless the attention-grabbing factor is, we’re in a position to hook up your entire button with the IBAction func, however not the menu merchandise’s selector, what ought to we do with the selector right here? does it should be connected with a perform too?

enter image description here



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments