Here is an idea:
you probably know of the dimensions of the screen, you know of the resolution of the squares, and at any time when a point on the screen is touched, you know this points x and y coordinates.
int xSquare = floor(x/squareResolution)
int ySquare = floor(y/squareResolution)
If you store all your squares in a one dimensional array, the square you want is
squares = new Square[gridResolution*gridResolution];
theSquareYouWant = squares[ySquare *gridResolution + xSquare]
If you store it in a 2d array you want square
squares = new Square[gridResolution][gridResolution];
theSquareYouWant = squares[xSquare][ySquare]
You should not use image buttons. If you want to animate a square being pressed, create an animated sprite or whatever at the space occupied by the square and then remove it once the animation has finished.