Search code examples
swiftibaction

Swift/Xcode - Multiple text fields for IBAction


I want to have multiple UI Text Fields to be associated with an IBAction. I dragged on dropped from the first text field and created the action, and then wrote the action code. I then dragged and dropped my other text fields to that same action.

When I hover over the action in the file, every one of my UI text fields is highlighted in the view controller, signifying to me that they should all be mapped to the IBAction.

However, only 1 (the very first one I originally created the IBAction with) functions as intended. Even though the other all appear to be associated with the action, only the original responds. Any advice?


Solution

  • So when I created the original IBAction I chose the even type as Primary Action Triggered. However, the default is Editing Did End. I assumed that when I connected other UITextField to that same action it would be associated as a Primary Action Triggered as well. This is apparently not the case, and I had to manually go in and change this for all the other text fields. Afterwards, they functioned as expected.