0

I'm trying to implement a board game, in which i need a board size of 40*26 buttons.

I implement this board as follows :

sizeX = 7.55;
sizeY = 7.35;
for (int i=0; i<nb_lignes; i++)
{
    for (int j=0; j<nb_colonnes; j++)
    {
        UIButton * test = [UIButton buttonWithType:UIButtonTypeRoundedRect];
        [test setFrame:CGRectMake((100-sizeX)+(j*(sizeX)), 50+(i*(sizeY)), (sizeX), (sizeY))];
        [test setBackgroundColor:[UIColor redColor]];
        [test setAlpha:0.5];
        [test setTitleColor:[UIColor clearColor] forState:UIControlStateNormal];
        [test setTitle:[NSString stringWithFormat:@"%i %i", j+1, i+1] forState:UIControlStateNormal];
        [test addTarget:self action:@selector(touchBouton:) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:test];
        [[LevelButton objectAtIndex:i] addObject:test];
    }
}

I haven't done any action that the game is really slow. For example, when i try to use the assistive touch, it goes really really slow. Have you got an idea of how could I improve the performances of my app ?

user1833903
  • 187
  • 3
  • 16

1 Answers1

0

Instead of using for loop you can try -[NSArray enumerateObjectsUsingBlock:]

For more details you can check this Stack Overflow answer about using it.

Community
  • 1
  • 1
Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56