PDA

View Full Version : how to make an editable grid?




newConvert
Apr 2, 2009, 11:02 AM
Hello Everyone,

Fairly new to the iphone dev, so I was hoping someone could help me out... couldn't find anything through a search.

I am making a free app for my friends and I that will keep track of a bunch of scores for various teams/sports that we are interested in... I am trying to make a large grid, for arguments sake 8x8 (64squares) and be able to edit/change the values in each one. IE click in a square and the numberpad pops up.

Any advice? I really can't think of a way to draw the grid. Thanks so much.



iphonedevelop18
Apr 2, 2009, 11:46 AM
just make an image of the grid on photo shop or something

admanimal
Apr 2, 2009, 11:47 AM
EDIT: nevermind

bboyjayz
Apr 2, 2009, 11:49 AM
Maybe you can do i thing like that:
this pice of code take an array of ImageView, and add the imageView on the mainView (here, i build a 5/5 grid). After what, if you want to check if the user push one of the images, you just have to write a touchesBegan method;.
Actually I don't if it's the best way to do this, but i know it works (i'm using it)

CGPoint position;
position.x = 100;
position.y = 200;
for(int i = 0; i<ROW; i++){
for(int j=0; j<COL; j++){
plateau[i][j] = [self newPieceViewWithImageNamed:@"blueSquare.png" atPostion:position];
[plateau[i][j] setEtat:0];
[self addSubview:plateau[i][j]];
position.x += 30;
dejaPasser[i][j] = NO;
}
position.y += 30;
position.x = 100;
}

PS: i've forogot to say that newPieceViewWithImageNamed:@"blueSquare.png" atPostion:position] just put the imageView at the position "position" with image named "blueSquare.png"...

newConvert
Apr 2, 2009, 02:24 PM
Maybe you can do i thing like that:
this pice of code take an array of ImageView, and add the imageView on the mainView (here, i build a 5/5 grid). After what, if you want to check if the user push one of the images, you just have to write a touchesBegan method;.
Actually I don't if it's the best way to do this, but i know it works (i'm using it)

CGPoint position;
position.x = 100;
position.y = 200;
for(int i = 0; i<ROW; i++){
for(int j=0; j<COL; j++){
plateau[i][j] = [self newPieceViewWithImageNamed:@"blueSquare.png" atPostion:position];
[plateau[i][j] setEtat:0];
[self addSubview:plateau[i][j]];
position.x += 30;
dejaPasser[i][j] = NO;
}
position.y += 30;
position.x = 100;
}

PS: i've forogot to say that newPieceViewWithImageNamed:@"blueSquare.png" atPostion:position] just put the imageView at the position "position" with image named "blueSquare.png"...

Thanks so much! Going to take a look at that and make sure I know whats going!