Creating selection buttons

off-topic

(Bruno) #1

Dears,

What is the best way to solve the following issue:

My project's UIView has 12 Labels at the left side and 12 Labels at the right side. Close to this UiView I have some Buttons. So I have 6 buttons at the left side, and 6 buttons at the right side.

Each of these buttons corresponds to its very close UiLabel:

If I could draw something it would be something like this:

          | Label1                 Label13 |

Button1 | Label2 Label14 | Button 7

          | Label3                 Label15 |

Button2 | Label4 Label16 | Button 8

          | Label5                 Label17 |

Button3 | Label6 Label18 | Button 9

          | Label7                 Label19 |

Button4 | Label8 Label20 | Button 10

          | Label9                 Label21 |

Button5 | Label10 Label22 | Button 11

          | Label11               Label23 |

Button6 | Label12 Label24 | Button 12

The purpose of these Buttons (Button1 up to 12), is to select a function or to insert a value in an Array of Strings. All Buttons will do the same thing. The Button 1 will call a function or enter a value based on what's written on Label 2. The Button 11 will call a function or Enter a value based on what's written on Label 22. Ok?

Imagine the following example:

          | ""                                            "" |

Button1 | NAV IDENT "" | Button 7

          |""                                             "" |

Button2 | WPT LIST DATALINK | Button 8

          | ""                                             ""|

Button3 | FPL LIST FLT SUM| Button 9

          | ""                                            "" |               

Button4 | POS SENSORS ""| Button 10

          |""                                             "" |     

Button5 | FIX INFO HOLD | Button 11

          | ""                                            "" |     

Button6 | DEPARTURE ARRIVAL | Button 12

Pressing the Button 2, should call a function corresponding to WPT LIST, the same for any other option.

I would like to have a function.

How can I do it?

On my last project for the same application, but on Excel VBA I used a Swith function and added a lot of cases and ifs, but I don't thing that's the best method.

I'm using XCode 9.4.1

Thank you so much!


(Joanna Carter) #2

This forum is for discussion of the Swift language, not how to build apps.

I suggest you take this to the Apple developer forums.

BTW, the idea of buttons and labels is not a good one; try looking at using a UICollectionView with two columns