[英]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 所以我有4行4列,每行和每列包含4个按钮
OOOO OOOO
OOOO OOOO
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. 因此,当我单击第一个O时,我希望xcode能够识别它在row1和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. 这虽然很乏味,但可以解决您的16按钮问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.