Created
November 9, 2015 06:22
-
-
Save johnny77221/2354b6e626ad5fd53438 to your computer and use it in GitHub Desktop.
rotate code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(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