int rand=((arc4random()%4)+1);
由于touch event
生成的数字,您将如何制作int rand
。
示例,如果生成的数字为1,2,2,3,4
,而您的4 buttons
标记为1,2,3,4
。
如何按照int rand
方法生成的数字顺序触摸对象?如何制作事件?
答案 0 :(得分:0)
让4个按钮给出一个动作
- (void)touchesBegan:(NSSet *)触及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;
}
}