단추로 UIViewController를 만들고 싶습니다. 사용자가 특정 순서로 4 개의 버튼을 누르길 원합니다. 내가 지금까지했던 것은 내가 다음 코드로 모든 버튼에 임의의 태그 번호를 제공한다는 것입니다 :단추가 iOS에서 특정 순서로 누름
그래서-(void)prepareArray {
self.arary = [[NSMutableArray alloc]init];
while (self.arary.count <4) {
int value = arc4random()%4;
BOOL isFound = [[self.arary filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:[NSString stringWithFormat:@"intValue == %d",value]]] count];
if(!isFound)
[self.arary addObject:[NSNumber numberWithInteger:value]];
}
NSLog(@"%@", arary);
button1.tag = [[arary objectAtIndex:0]intValue];
button2.tag = [[arary objectAtIndex:1]intValue];
button3.tag = [[arary objectAtIndex:2]intValue];
button4.tag = [[arary objectAtIndex:3]intValue];
내 질문은 : 나는 버튼을 누르는 순서를 가지고하는 방법을 만드는 방법 0에서 3까지? 나는 case와 if 문을 써서 시도했는데 이것을 알아낼 수 없다?
모든 버튼에서 정수 값을 설정해야 시퀀스 순서를 알 수 있습니다. 버튼 코드를 보여 주시면 답변을 드릴 수 있습니다. – NullData
코드는 모든 버튼에 정수 값을 설정하는 코드입니다 . 컨트롤러가 시작할 때마다 정수가 변경됩니다. 그게 내가 왜 추적하고 싶은지 0,1,2,3이 될 버튼을 누르라는 정확한 순서를 말해 보자. – axel
버튼 시퀀스를 얻기위한 조건을두기가 어려워요? – NullData