int rand=((arc4random()%4)+1);
touch event
から生成された数字を元に、どのように作成しますかint rand
。
生成された数字があり、タグ1,2,2,3,4
が付いている場合の例。4 buttons
1,2,3,4
rand
intメソッドで生成された番号順にオブジェクトをタッチする必要があるイベントをどのように作成しますか?
int rand=((arc4random()%4)+1);
touch event
から生成された数字を元に、どのように作成しますかint rand
。
生成された数字があり、タグ1,2,2,3,4
が付いている場合の例。4 buttons
1,2,3,4
rand
intメソッドで生成された番号順にオブジェクトをタッチする必要があるイベントをどのように作成しますか?
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;
}
}