0
int rand=((arc4random()%4)+1);

touch eventから生成された数字を元に、どのように作成しますかint rand

生成された数字があり、タグ1,2,2,3,4が付いている場合の例。4 buttons1,2,3,4

randintメソッドで生成された番号順にオブジェクトをタッチする必要があるイベントをどのように作成しますか?

4

1 に答える 1

0

4つのボタンでワンアクションにする

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)イベント

{

rand=((arc4random()%4)+1);

}

-(IBAction)myMethod {

switch (rand)
{

case 1:
//Do for first button tag
break;

case 2:
//Do for second button tag
break;

case 3:
//Do for third button tag
break;

case 4:
//Do for fourth button tag
break;


default:
break;
}

}
于 2013-06-03T06:59:15.947 に答える