【发布时间】:2014-12-04 22:51:27
【问题描述】:
我正在尝试实现一个棋盘游戏,其中我需要一个 40*26 按钮的棋盘大小。
我按如下方式实现这个板:
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];
}
}
我没有做任何动作说游戏真的很慢。例如,当我尝试使用辅助触摸时,它真的很慢。 您知道如何提高应用的性能吗?
【问题讨论】:
-
nb_lignes 和 nb_lignes 是否包含数组计数??
标签: ios objective-c arrays performance uibutton