简体   繁体   中英

How can I have my iOS app recognize which row/column a button is in?

So I have 4 rows and 4 columns and each row and column contains 4 buttons

OOOO

OOOO

OOOO

OOOO

So when I click on the first O. I want xcode to recognize that it is in row1 and column 1.

I have already declared everything as buttons, ints,etc. But I need help defining rows/columns and placing these buttons in that row/column.

I am going to assume that these buttons are created using storyboard and that each one has a unique name. Provided all of this, you can create a 2-dimensional array adding each of these buttons to the appropriate spot in the array.

ex. array[0][0] = button0

This, while tedious, will solve this problem for your 16 button problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM