Skip to content

Instantly share code, notes, and snippets.

@johnny77221
Created November 9, 2015 06:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnny77221/2354b6e626ad5fd53438 to your computer and use it in GitHub Desktop.
Save johnny77221/2354b6e626ad5fd53438 to your computer and use it in GitHub Desktop.
rotate code
-(IBAction)startRotation:(id)sender
{
if (rotateTimer) {
[rotateTimer invalidate];
}
rotateTimer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(rotate) userInfo:nil repeats:YES];
}
-(IBAction)stopRotation:(id)sender
{
[rotateTimer invalidate];
rotateTimer = nil;
int accumulatedScore = 0;
for (int i=0; i<[self.dataArray count]; i++) {
accumulatedScore += [self.dataArray[i][@"score"] intValue];
if (accumulatedScore > degree) {
NSString *selectedItem = self.dataArray[i][@"name"];
UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"選到" message:selectedItem preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action = [UIAlertAction actionWithTitle:@"關閉" style:UIAlertActionStyleDefault handler:nil];
[ac addAction:action];
[self presentViewController:ac animated:YES completion:nil];
break;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment